I have this JSON response (contained in response
variable):
{
"data": [
{
"requestedUsername": "string",
"hasVerifiedBadge": true,
"id": 0,
"name": "string",
"displayName": "string"
}
]
}
And I want to get values like "name", "displayName", etc… But I can’t figure out how to get to them, because it’s located inside a dictionary which, in turn, is located inside an array.
I tried beginning with this:
console.log(response.data[0])
But even it returns undefined
. So what would the solution be?
2
Answers
Problem solved. Solution:
If the variable "response" indeed has that value you should be able to get them with:
var theName = response.data[0].name;