[wp-trac] [WordPress Trac] #11963: json_decode() only supports only "stdClass Object" but no "array"
WordPress Trac
wp-trac at lists.automattic.com
Thu Jan 21 10:49:39 UTC 2010
#11963: json_decode() only supports only "stdClass Object" but no "array"
--------------------------+-------------------------------------------------
Reporter: carbolineum | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Unassigned
Component: Optimization | Version: 2.9.1
Severity: normal | Keywords: json_decode, array
--------------------------+-------------------------------------------------
Comment(by nacin):
The compat version of {{{json_decode()}}} is designed to only initialize
the {{{Services_JSON()}}} class once, even if called multiple times. Using
the diff you suggest, if you used both {{{json_decode( $json, true )}}}
and {{{json_decode( $json, false )}}} in a script, whichever was called
first would be what you would get for both.
There are two ways to do this if we wish to support this level of
compatibility. We could allow {{{Services_JSON()}}} to be initialized a
second time using the loose typing option if an array is requested... or,
potentially less overhead, convert the result of {{{$wp_json->decode()}}}
if arrays are what is requested.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/11963#comment:1>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list