php在json中访问属性
我已经在php在json中访问属性,php,json,Php,Json,我已经在$response=$result->response中存储了以下已解码的json: object(stdClass)#6 (5) { ["EmailAddress"]=> string(18) "email@gmail.com" ["Name"]=> string(0) "" ["Date"]=> string(19) "2011-10-09 19:32:00" ["State"]=> string(6) "Active" ["Custom
$response=$result->response中存储了以下已解码的json代码>:
object(stdClass)#6 (5) {
["EmailAddress"]=> string(18) "email@gmail.com"
["Name"]=> string(0) ""
["Date"]=> string(19) "2011-10-09 19:32:00"
["State"]=> string(6) "Active"
["CustomFields"]=> array(1) {
[0]=>object(stdClass)#7 (2) {
["Key"]=>string(2) "id"
["Value"]=>string(6) "Dl9lIz"
}
}
我已经可以通过以下方式访问主要属性(电子邮件地址、名称等):
但是我需要访问CustomFields对象中的“Value”
部分。我不知道怎么挖那么深。我正试图用PHP实现这一点
有什么建议吗?它包含在数组自定义字段
的第一个元素([0]
)中,因此您可以使用数组索引后的对象操作符(->
)访问它
print $response->CustomFields[0]->Value;
print $response->CustomFields[0]->Value;