Reputation:
I am having issues with reading some data where I'm getting undefined:
obj = {
"people": [
{
"id": "123",
"description": "some desc",
"names": [
{
"name": "Mark"
}]
}]
}
console.log(obj.people[0].names.name);
What I'm I doing wrong here?
Upvotes: 2
Views: 4084
Reputation: 10695
names
is also an array.
Try this,
console.log(obj.people[0].names[0].name);
Upvotes: 0
Reputation: 68393
names
is an array, make it
console.log(obj.people[0].names[0].name);
Upvotes: 2