Accessing data in a JSON object (parsed) in JavaScript

I need to get "messages" of data from this JSON object. How can i do this in javascript?

To access, for example, the last name that I just use:

response[i].user.lastname 

But how can I access messages?

 [ { "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 " } } ] 
+7
source share
3 answers
 response[i].user.last_message.message.created_at 

And here is a live demonstration .

+8
source

response[i].user.last_message.message

+3
source

Some examples:

 alert(response[0].user.last_message.message.id); alert(response[0].user.nickname); alert(response[0].user.lstname); 

and working code:

JSFiddle working example

+2
source

All Articles