Implement the 2nd parameter of json_decode() for back-compat purposes. Returns an associative array instead of an object. For the recursive object handling, Props carbolineum. Fixes #11963

git-svn-id: http://svn.automattic.com/wordpress/trunk@13863 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
dd32 2010-03-28 04:42:44 +00:00
parent adb825f6d0
commit ceb1acf3f7
1 changed files with 6 additions and 1 deletions

View File

@ -148,9 +148,14 @@ if ( !function_exists('json_decode') ) {
$res = $wp_json->decode( $string );
if ( $assoc_array )
$res = get_object_vars( $res );
$res = _json_decode_object_helper( $res );
return $res;
}
function _json_decode_object_helper($data) {
if ( is_object($data) )
$data = get_object_vars($data);
return is_array($data) ? array_map(__FUNCTION__, $data) : $data;
}
}
// pathinfo that fills 'filename' without extension like in PHP 5.2+