From 0773ef03a60ad6410c44a290f78c2fdfe346e5e8 Mon Sep 17 00:00:00 2001 From: Dion Hulse 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: https://develop.svn.wordpress.org/trunk@13862 602fd350-edb4-49c9-b593-d223f7449a82 --- 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; } }