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

git-svn-id: http://svn.automattic.com/wordpress/trunk@13862 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
dd32 2010-03-28 04:35:42 +00:00
parent 8abdcecbfe
commit adb825f6d0
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;
}
}