Util/Json: Support PHP 5.3

This commit is contained in:
Markus Frosch 2017-06-13 09:29:59 +02:00
parent 3d3b1cdf4f
commit b86789ecc5
1 changed files with 6 additions and 1 deletions

View File

@ -43,7 +43,12 @@ class Json
*/
public static function decode($json, $assoc = false, $depth = 512, $options = 0)
{
$decoded = json_decode($json, $assoc, $depth, $options);
if (version_compare(phpversion(), '5.4.0', '<')) {
$decoded = json_decode($json, $assoc, $depth);
} else {
$decoded = json_decode($json, $assoc, $depth, $options);
}
if (json_last_error() !== JSON_ERROR_NONE) {
throw new JsonDecodeException('%s: %s', static::lastErrorMsg(), var_export($json, true));
}