ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilJsonUtil.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4
13{
14 public static function encode($mixed, $suppress_native = false)
15 {
16 if (!$suppress_native && self::checkNativeSupport())
17 {
18 return json_encode($mixed);
19 }
20 else
21 {
22 include_once './Services/JSON/include/json.php';
24 return $json->encode($mixed);
25 }
26 }
27
28 public static function decode($json_notated_string, $suppress_native = false)
29 {
30 if (!$suppress_native && self::checkNativeSupport())
31 {
32 return json_decode($json_notated_string);
33 }
34 else
35 {
36 include_once './Services/JSON/include/json.php';
38 return $json->decode($json_notated_string);
39 }
40 }
41
42 public static function checkNativeSupport()
43 {
44 return function_exists('json_encode') && function_exists('json_decode');
45 }
46}
const SERVICES_JSON_SUPPRESS_ERRORS
Behavior switch for Services_JSON::decode()
Definition: JSON.php:92
JSON (Javascript Object Notation) functions with backward compatibility for PHP version < 5....
static encode($mixed, $suppress_native=false)
static decode($json_notated_string, $suppress_native=false)
static checkNativeSupport()