Not sure about posting rules, but I will tell you out of the gate that this is a repeat question of this one, but I am asking if this is the \"best practice\" way to do this
@jondavidjohn - you can use this javascript lib, DefiantJS (http://defiantjs.com), with which you can filter matches using XPath on JSON structures. To put it in JS code:
var data = [
{
"restaurant": {
"name": "McDonald's",
"food": "burger"
}
},
{
"restaurant": {
"name": "KFC",
"food": "chicken"
}
},
{
"restaurant": {
"name": "Pizza Hut",
"food": "pizza"
}
}
].
res = JSON.search( data, '//*[food="pizza"]' );
console.log( res[0].name );
// Pizza Hut
Here is a working fiddle;
http://jsfiddle.net/hbi99/weKVL/
DefiantJS extends the global object with the method "search" and returns an array with matches (empty array if no matches were found). You can try out the lib and XPath queries using the XPath Evaluator here:
http://www.defiantjs.com/#xpath_evaluator