WordPress.org

Make WordPress Core

Changeset 13863


Ignore:
Timestamp:
03/28/10 04:42:44 (5 years ago)
Author:
dd32
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/compat.php

    r13862 r13863  
    149149        $res = $wp_json->decode( $string ); 
    150150        if ( $assoc_array ) 
    151             $res = get_object_vars( $res ); 
     151            $res = _json_decode_object_helper( $res ); 
    152152        return $res; 
     153    } 
     154    function _json_decode_object_helper($data) { 
     155        if ( is_object($data) ) 
     156            $data = get_object_vars($data); 
     157        return is_array($data) ? array_map(__FUNCTION__, $data) : $data; 
    153158    } 
    154159} 
Note: See TracChangeset for help on using the changeset viewer.