微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何使用PHP阅读此JSON?

我是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作为字符串.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐