X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fjson%2FFormatJson.php;h=cae3f12a5e772caeaba01c852d6b2d5fe325fd34;hb=a86ae844e648c31ad7216738d4914802c0e60c07;hp=cf49c17bec06e37a95e1ed1a2af2acb8c95c25ed;hpb=539ab6f5e5f730a4dae78fa34780689897ec4675;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/json/FormatJson.php b/includes/json/FormatJson.php index cf49c17bec..cae3f12a5e 100644 --- a/includes/json/FormatJson.php +++ b/includes/json/FormatJson.php @@ -1,26 +1,50 @@ encode( $value, $isHtml ); } else { @@ -30,10 +54,10 @@ class FormatJson { /** * Decodes a JSON string. - * + * * @param $value String: the json string being decoded. * @param $assoc Boolean: when true, returned objects will be converted into associative arrays. - * + * * @return Mixed: the value encoded in json in appropriate PHP type. * Values true, false and null (case-insensitive) are returned as true, false * and &null; respectively. &null; is returned if the json cannot be @@ -41,15 +65,13 @@ class FormatJson { */ public static function decode( $value, $assoc = false ) { if ( !function_exists( 'json_decode' ) ) { - $json = new Services_JSON(); + $json = $assoc ? new Services_JSON( SERVICES_JSON_LOOSE_TYPE ) : + new Services_JSON(); $jsonDec = $json->decode( $value ); - if( $assoc ) { - $jsonDec = wfObjectToArray( $jsonDec ); - } return $jsonDec; } else { return json_decode( $value, $assoc ); } } - -} \ No newline at end of file + +}