|
|
@ -81,32 +81,26 @@ class BaseJson |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected static function processData($data, &$expressions, $expPrefix) |
|
|
|
protected static function processData($data, &$expressions, $expPrefix) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (is_array($data)) { |
|
|
|
if (is_object($data)) { |
|
|
|
foreach ($data as $key => $value) { |
|
|
|
|
|
|
|
if (is_array($value) || is_object($value)) { |
|
|
|
|
|
|
|
$data[$key] = static::processData($value, $expressions, $expPrefix); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return $data; |
|
|
|
|
|
|
|
} elseif (is_object($data)) { |
|
|
|
|
|
|
|
if ($data instanceof JsExpression) { |
|
|
|
if ($data instanceof JsExpression) { |
|
|
|
$token = "!{[$expPrefix=" . count($expressions) . ']}!'; |
|
|
|
$token = "!{[$expPrefix=" . count($expressions) . ']}!'; |
|
|
|
$expressions['"' . $token . '"'] = $data->expression; |
|
|
|
$expressions['"' . $token . '"'] = $data->expression; |
|
|
|
return $token; |
|
|
|
return $token; |
|
|
|
} else { |
|
|
|
} |
|
|
|
$data = $data instanceof Arrayable ? $data->toArray() : get_object_vars($data); |
|
|
|
$data = $data instanceof Arrayable ? $data->toArray() : get_object_vars($data); |
|
|
|
$result = array(); |
|
|
|
if ($data === array() && !$data instanceof Arrayable) { |
|
|
|
|
|
|
|
return new \stdClass(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (is_array($data)) { |
|
|
|
foreach ($data as $key => $value) { |
|
|
|
foreach ($data as $key => $value) { |
|
|
|
if (is_array($value) || is_object($value)) { |
|
|
|
if (is_array($value) || is_object($value)) { |
|
|
|
$result[$key] = static::processData($value, $expressions, $expPrefix); |
|
|
|
$data[$key] = static::processData($value, $expressions, $expPrefix); |
|
|
|
} else { |
|
|
|
|
|
|
|
$result[$key] = $value; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return $result; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
|
|
|
|
return $data; |
|
|
|
return $data; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|