diff --git a/inc/JSON.php b/inc/JSON.php index 332827f4ca08ea63911298956b0a317234bc483a..d1fbd404a1b1acab175d3e7fa806045f38f2eb2a 100644 --- a/inc/JSON.php +++ b/inc/JSON.php @@ -130,6 +130,7 @@ class JSON { /** * encodes an arbitrary variable into JSON format + * If available the native PHP JSON implementation is used. * * @param mixed $var any number, boolean, string, array, or object to be encoded. * see argument 1 to JSON() above for array-parsing behavior. @@ -140,6 +141,7 @@ class JSON { * @access public */ function encode($var) { + if (function_exists('json_encode')) return json_encode($var); switch (gettype($var)) { case 'boolean': return $var ? 'true' : 'false'; @@ -352,6 +354,7 @@ class JSON { /** * decodes a JSON string into appropriate variable + * If available the native PHP JSON implementation is used. * * @param string $str JSON-formatted string * @@ -363,6 +366,7 @@ class JSON { * @access public */ function decode($str) { + if (function_exists('json_decode')) return json_decode($str); $str = $this->reduce_string($str); switch (strtolower($str)) {