0

I don't know how to get every first name from json text below:

[
{
"Contact":{
 "id":"4",
 "first_name":"Richat",
 "last_name":"Chhay",
 "phone":"930345435",
 }
},
{
"Contact":{
 "id":"31",
 "first_name":"Dara",
 "last_name":"Hong",
 "phone":"930345435",
 }
}
]

what I want is how to get first_name?

asked May 30, 2014 at 9:11
1

3 Answers 3

1

Try $.each method to retrieve the value

$.each(data,function(i,val){
 alert(val.Contact.first_name);
});

Demo

Rajaprabhu Aravindasamy
67.2k17 gold badges107 silver badges133 bronze badges
answered May 30, 2014 at 9:16
Sign up to request clarification or add additional context in comments.

Comments

0

You can do this

arr.forEach(function(elm){
 console.log(elm.Contact.first_name);
});

FIDDLE

answered May 30, 2014 at 9:14

Comments

0

Get it as jsonArray and execute a loop on it, for each value in array get the name and output where you want it.

answered May 30, 2014 at 9:15

1 Comment

please add some code for better understanding of OP

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.