我是JSON格式的新手,在我阅读的教程中,我不太清楚如何使用PHP解析.所以我有这个:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-67.593742,
10.24462
]
},
"properties": {
"id": "669163449",
"accuracyInMeters": 0,
"timeStamp": 1301841780,
"reverseGeocode": "Maracay, Venezuela",
"photoUrl": "https://www.google.com/latitude/apps/badge/api?type=photo&photo=Df7VGy8BAAA.9of56owsf4wI6F4odEQ",
"photoWidth": 96,
"photoHeight": 96,
"placardUrl": "https://g=true&stale=false&lod=4&format=png",
"placardWidth": 56,
"placardHeight": 59
}
}
]
}
我想要回显坐标和reverseGeocode.任何人都可以把我放在正确的方向吗?
解决方法:
试试跑步
$decoded = json_decode($json_string, true);
print_r($decoded);
print_r($decoded["features"][0]["geometry"]["coordinates"]);
echo $decoded["features"][0]["properties"]["reverseGeocode"];
其中$json_string是您的样本JSON作为字符串.