在JavaScript中访问JSON对象中的数据(已解析) [英] Access data in a JSON object (parsed) in JavaScript

查看:131
本文介绍了在JavaScript中访问JSON对象中的数据(已解析)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从这个JSON对象获取数据消息。如何在JavaScript中执行此操作?

I need to get the data "messages" from this JSON object. How can I do it in JavaScript?

要访问我刚才使用的姓氏:

To access for example the lastname I just use:

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": "the@email.com"
        }
    }
]


推荐答案

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

这是一个现场演示

这篇关于在JavaScript中访问JSON对象中的数据(已解析)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆