mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-31 01:34:09 +02:00
Util/Json: Make encode compatible to PHP < 5.5
This commit is contained in:
parent
2510155206
commit
414ba16d8a
@ -23,7 +23,13 @@ class Json
|
|||||||
*/
|
*/
|
||||||
public static function encode($value, $options = 0, $depth = 512)
|
public static function encode($value, $options = 0, $depth = 512)
|
||||||
{
|
{
|
||||||
|
if (version_compare(phpversion(), '5.4.0', '<')) {
|
||||||
|
$encoded = json_encode($value);
|
||||||
|
} else if (version_compare(phpversion(), '5.5.0', '<')) {
|
||||||
|
$encoded = json_encode($value, $options);
|
||||||
|
} else {
|
||||||
$encoded = json_encode($value, $options, $depth);
|
$encoded = json_encode($value, $options, $depth);
|
||||||
|
}
|
||||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||||
throw new JsonEncodeException('%s: %s', static::lastErrorMsg(), var_export($value, true));
|
throw new JsonEncodeException('%s: %s', static::lastErrorMsg(), var_export($value, true));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user