From b86789ecc5bdb9f2f89c3c89af64a5adf18ad851 Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Tue, 13 Jun 2017 09:29:59 +0200 Subject: [PATCH] Util/Json: Support PHP 5.3 --- library/Icinga/Util/Json.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Util/Json.php b/library/Icinga/Util/Json.php index c2c1f7a6d..3bd988bc0 100644 --- a/library/Icinga/Util/Json.php +++ b/library/Icinga/Util/Json.php @@ -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)); }