我有一个PHP
脚本成功地使用JSON
字符串解码为PHP
对象:PHP访问解码JSON
$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]
以及许多更多的变体。
有没有人看到我做错了什么?
非常感谢, 布雷特
完美!非常感谢;-)只要SO允许,我会立即接受答案 – Brett 2011-06-07 20:17:56
如果查看输出结果,您会看到'$ decodedJSON'和'response'属性都是对象,这就是为什么您需要用箭头符号' - >'来访问它们。 – jokkedk 2011-06-07 20:23:30