How to select data in JSON based on other JSON data? Javascript
- by user1699030
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.