00001 <?php
00002
00003
00004
00005 if( !(defined( 'MEDIAWIKI' ) ) ) {
00006 die( 1 );
00007 }
00008
00009 class FormatJson{
00010 public static function encode($value, $isHtml=false){
00011
00012
00013
00014 if (!function_exists('json_encode') || $isHtml || strtolower(json_encode("\xf0\xa0\x80\x80")) != '\ud840\udc00') {
00015 $json = new Services_JSON();
00016 return $json->encode($value, $isHtml) ;
00017 } else {
00018 return json_encode($value);
00019 }
00020 }
00021 public static function decode( $value, $assoc=false ){
00022 if (!function_exists('json_decode') ) {
00023 $json = new Services_JSON();
00024 $jsonDec = $json->decode( $value );
00025 if( $assoc )
00026 $jsonDec = wfObjectToArray( $jsonDec );
00027 return $jsonDec;
00028 } else {
00029 return json_decode( $value, $assoc );
00030 }
00031 }
00032 }