Level 6
- you need to use
JSON.parsenotJSON.stringify - use
population.roles[0].nameto access the name property of the first entry
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
$.get("https://website.com/uploads/json.json", function(data) {
var population = JSON.stringify(data);
});
{
"roles": [
{"name": "admin", "id": 1}, // 1
{"name": "sales", "id": 2} // 2
]
}
How do I get ['roles']['name'] 1
How do I get ['roles']['name'] 2
I try to explain what I want with the strange code above.
Please or to participate in this conversation.