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?
Take the 2-minute tour
×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
That is the straight forward to do this. If you need fast access multiple times, you should create a map keyed by the property name that you're searching by. Here's a function that takes arrays and builds keyed maps. It's not all-purpose, but you should be able to modify it for your own use.
|
|||
|
@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:
Here is a working fiddle; 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: |
||||
|