mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-06 01:28:19 +01:00
Fix: Pb in json function for objects
This commit is contained in:
@@ -45,7 +45,13 @@ if (! function_exists('json_encode'))
|
||||
*/
|
||||
function dol_json_encode($elements)
|
||||
{
|
||||
$num = count($elements);
|
||||
$num=count($elements);
|
||||
if (is_object($elements)) // Count number of properties for an object
|
||||
{
|
||||
$num=0;
|
||||
foreach($elements as $key => $value) $num++;
|
||||
}
|
||||
//var_dump($num);
|
||||
|
||||
// determine type
|
||||
if (is_numeric(key($elements)))
|
||||
@@ -56,7 +62,7 @@ function dol_json_encode($elements)
|
||||
{
|
||||
if (is_array($elements[$i]) || is_object($elements[$i])) $output.= json_encode($elements[$i]);
|
||||
else $output .= _val($elements[$i]);
|
||||
if($i !== $last) $output.= ',';
|
||||
if ($i !== $last) $output.= ',';
|
||||
}
|
||||
$output.= ']';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user