我有一个PHP脚本,该脚本使用以下命令将JSON字符串成功解码为PHP对象:

$decodedJSON = json_decode($responseString);


$decodedJSON打印到响应时,我得到:

stdClass Object
(
    [response] => 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
)


我的问题是:如何访问“字段”数据?我试过使用$decodedJSON["fields"]以及$decodedJSON[0]["fields"]$decodedJSON[0][2]以及许多其他变体。

有人看到我在做什么错吗?

非常感谢,
布雷特

最佳答案

尝试使用$decodedJSON->response->fields

09-27 10:35