我正在向 Google 的反向地理编码系统发出请求,它们返回一个大型 JSON 对象,我似乎无法访问这些属性。响应看起来像这样:
{
"results" : [
"address_components" : [
{
"long_name" : "123",
"short_name" : "123",
"types" : [ "street_number" ]
},
{
etc.
}
],
"formatted_address" : "123 Broadway, New York City, NY 10002, USA"
]
}
解码后它看起来像这样:
stdClass Object (
[results] => Array (
[0] => stdClass Object (
[address_components] => Array (
[0] => stdClass Object (
[long_name] => 123
[short_name] => 123
[types] => Array ( [0] => street_number )
)
)
)
[formatted_address] => 123 Broadway, New York City, NY 10002, USA
)
)
如何访问 [formatted_address] 属性?我试过$geoCode->["results"]->formatted_address
了,但没有返回值。我被难住了,谢谢!