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

git-svn-id: https://develop.svn.wordpress.org/trunk@13862 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dion Hulse 2010-03-28 04:35:42 +00:00
parent 85b5a63f56
commit 0773ef03a6
1 changed files with 5 additions and 2 deletions

View File

@ -138,7 +138,7 @@ if ( !function_exists('json_encode') ) {
}
if ( !function_exists('json_decode') ) {
function json_decode( $string ) {
function json_decode( $string, $assoc_array = false ) {
global $wp_json;
if ( !is_a($wp_json, 'Services_JSON') ) {
@ -146,7 +146,10 @@ if ( !function_exists('json_decode') ) {
$wp_json = new Services_JSON();
}
return $wp_json->decode( $string );
$res = $wp_json->decode( $string );
if ( $assoc_array )
$res = get_object_vars( $res );
return $res;
}
}