From adb825f6d08f6336f1f50e06eb8acb5a08cffcde Mon Sep 17 00:00:00 2001 From: dd32 Date: Sun, 28 Mar 2010 04:35:42 +0000 Subject: [PATCH] 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 --- wp-includes/compat.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/wp-includes/compat.php b/wp-includes/compat.php index 45d746bec1..f1e118babb 100644 --- a/wp-includes/compat.php +++ b/wp-includes/compat.php @@ -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; } }