Reputation: 1382
This is probably a really stupid question, but I'm getting a JSON object returned by an API call and I can't for the life of me figure out how to get the values out of it. After I make the call, I pretty print the JSON object and it shows the following:
[
{
"link_request": {
"success": true,
"link": "https://www.blah.com"
},
"errors": null
}
]
I want to be able to get at that link value. I've tried both of the following, but neither works.
var link = data.query.link;
var link = data['query']['link']
Any help? Thanks!
Upvotes: 1
Views: 1370
Reputation: 103
Use the below code to get link:
jsonArray = [ {
"link_request": {
"success": true,
"link": "https://www.blah.com"
},
"errors": null
}
];
console.log(jsonArray[0].link_request.link)
Upvotes: 0