在 JavaScript 中访问 JSON 对象(已解析)中的数据

2024-01-31

我需要从这个 JSON 对象获取数据“消息”。我怎样才能用 JavaScript 做到这一点?

例如,要访问姓氏,我只需使用:

response[i].user.lastname

但我怎样才能访问这些消息呢?

[
    {
        "user": {
            "last_message": {
                "message": {
                    "created_at": "2011-04-16T16:40:56Z",
                    "updated_at": "2011-04-16T16:40:56Z",
                    "to": null,
                    "id": 10,
                    "user_id": 28,
                    "message": "This is a message"
                }
            },
            "nickname": "thenicky",
            "id": 28,
            "lastname": "white",
            "firstname": "Sean",
            "bio": "A short bio",
            "email": "[email protected] /cdn-cgi/l/email-protection"
        }
    }
]

response[i].user.last_message.message.created_at

这是一个现场演示 http://jsfiddle.net/Dwxj2/1/.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在 JavaScript 中访问 JSON 对象(已解析)中的数据 的相关文章

随机推荐