How to select data in JSON based on other JSON data? Javascript
Posted
by
user1699030
on Stack Overflow
See other posts from Stack Overflow
or by user1699030
Published on 2012-09-26T03:29:01Z
Indexed on
2012/09/26
3:37 UTC
Read the original article
Hit count: 121
JavaScript
|JSON
Is it possible to select certain data in a JSON Object using other data in the same JSON Object. Similar to MySQL. For example:
myObj = {"elements" : [ { "name" : "Hydrogen", "symbol" : "H" }, { "name" : "Silver", "symbol" : "Ag" }]};
I want to select "Hydrogen" where the symbol is "H". Instead of having to put in something like this:
document.getElementByID("TEST").innerHTML = myObj.elements[0].name;
Thank you in advance.
© Stack Overflow or respective owner