3 * simple wrapper for json_econde and json_decode that falls back on Services_JSON class
5 if( !(defined( 'MEDIAWIKI' ) ) ) {
10 public static function encode($value, $isHtml=false){
11 // Some versions of PHP have a broken json_encode, see PHP bug
12 // 46944. Test encoding an affected character (U+20000) to
14 if (!function_exists('json_encode') || $isHtml || strtolower(json_encode("\xf0\xa0\x80\x80")) != '\ud840\udc00') {
15 $json = new Services_JSON();
16 return $json->encode($value, $isHtml) ;
18 return json_encode($value);
21 public static function decode( $value, $assoc=false ){
22 if (!function_exists('json_decode') ) {
23 $json = new Services_JSON();
24 $jsonDec = $json->decode( $value );
26 $jsonDec = wfObjectToArray( $jsonDec );
29 return json_decode( $value, $assoc );