I have the following variable returned from php to JavaScript: [{"id":"34"}, {"id":"35"}, ...]
. I would like, the value of "id". How do I do that using JSON?
Asked
Active
Viewed 34 times
0

Mayank Pandeyz
- 25,704
- 4
- 40
- 59

user1400382
- 9
- 2
-
3Please [edit] your question to show your current code that returns the "variable" to JS. Are you asking how to write some sort of loop that does something with the id from each item in the array, or...? – nnnnnn Feb 21 '17 at 05:17
1 Answers
3
Try this:
var obj = [{"id":"34"}, {"id":"35"}];
console.log(obj[0]['id']);
Note: To make it dynamic use JS loop

Mayank Pandeyz
- 25,704
- 4
- 40
- 59