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?

1

3 Answers 3

1

Try $.each method to retrieve the value

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

Demo

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

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.

1 Comment

please add some code for better understanding of OP

Your Answer

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.