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: https://develop.svn.wordpress.org/trunk@13863 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dion Hulse 2010-03-28 04:42:44 +00:00
parent 0773ef03a6
commit 9393b90872
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+