ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 }