开发者

PHP Accessing decoded JSON

I have a PHP script which successfully decodes a JSON string into a PHP object using:

$decodedJSON = json_decode($responseString);

And when $decodedJSON is printed to the response, I get:

stdClass Object
(
    [res开发者_Go百科ponse] => stdClass Object
        (
            [total_rows] => 2379
            [data] => Array
                (
                    [0] => Array
                        (
                            [0] => zPKfssdfg456hwCQp6XpogfTsjc
                            [1] => 3456gg4-b7ea-4bcf1680c619
                            [2] => Title Description Here.
                            [3] => Example Address 
                            [4] => 
                            [5] => 
                            [6] => Exmaple City
                            [7] => CA
                            [8] => US
                            [9] => 95616
                            [10] => (555) 555-1212
                            [11] => 
                            [12] => Food & Beverage
                            [13] => 
                            [14] => 
                            [15] => 62.79901
                            [16] => -92.80102
                            [17] => 1
                        )

                    [1] => Array
                        (
                            [0] => zPKfl6ylrwCQp6XpogfTsjc
                            [1] => 98e9945a-b7ea-4bcf1680c619
                            [2] => Title Description Here.
                            [3] => Example Address 
                            [4] => 
                            [5] => 
                            [6] => Exmaple City
                            [7] => CA
                            [8] => US
                            [9] => 95616
                            [10] => (555) 555-1212
                            [11] => 
                            [12] => Food & Beverage
                            [13] => 
                            [14] => 
                            [15] => 62.79901
                            [16] => -92.80102
                            [17] => 1
                        )

                )

            [fields] => Array
                (
                    [0] => subject_key
                    [1] => factual_id
                    [2] => name
                    [3] => address
                    [4] => address_extended
                    [5] => po_box
                    [6] => locality
                    [7] => region
                    [8] => country
                    [9] => postcode
                    [10] => tel
                    [11] => fax
                    [12] => category
                    [13] => website
                    [14] => email
                    [15] => latitude
                    [16] => longitude
                    [17] => status
                )

            [rows] => 10
            [cache-state] => CACHED
            [big-data] => 1
            [subject_columns] => Array
                (
                    [0] => 1
                )

        )

    [version] => 2
    [status] => ok
)

My question is this: how do I access the "fields" data? I've tried using $decodedJSON["fields"] as well as $decodedJSON[0]["fields"] and $decodedJSON[0][2] and many many more variations.

Does anyone see what I am doing wrong?

Many thanks, Brett


Try using $decodedJSON->response->fields


Well you can decode it to an associated array:
$decodedJSON = json_decode($responseString, true);
and then you can access as you were trying

OR: $decodedJSON->response->fields

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜