Possible Duplicate:
I have a nested data structure / JSON, how can I access a specific value?
I have a JSON that represents a list of bird species. Each bird is an object in the JSON. Within each object there are fields that represent locations. The locations are coded alphanumerically like ['P1UBA', 'P1UBC', etc]. A value of 1 in these fields represents presence while a 0 represents absence.
The code below shows one of these objects (there are 150 in the entire JSON).
[
{
"Species": "AMAV",
"Common Name": "AMERICAN AVOCET",
"Order": "Shorebirds",
"Family": "Avocets",
"P1UBA": "0",
"P1UBC": "1",
"P1UBF": "0",
"P1UBG": "0",
"P1ABA": "0",
"P1ABC": "0",
"P1ABF": "1",
"P1ABFb": "0",
"P1ABG": "0",
"P1USA": "0",
"P1USC": "0",
}
]
How could I search through this object and return location fields==1? Ideally I would create a new array which is a string of those fields==1
Using the object above this would result in a new string of
var birdsMatch=['P1UBC','P1ABF']
I'd like to use jquery but am open to a pure javascript solution if it is more efficient