Motivation
Performance
Current behavior
Each time I pass a path it needs to be parsed and the queried for all possible matching items
Desired behavior
Be able to create and object for a path that stores the parsed query and allows me to execute it many times, skipping the overhead of path parsing. Additionally it would be good to specify the search limit.
Example:
constbookTitlePath=newJSONPath<string>('$..book[*].title');constbookPricePath=newJSONPath<number>('$..book[*].price');functiongetFirstBook(storeData: object): string{returnbookTitlePath.value(storeData);// Returns first match}// Consider books are in desc order of salesfunctiongetAveragePriceOfBestSellingBooks(storeData: object): number{constprices: number[]=bookPricePath.query(storeData,10);// Get up to 10 elements// The only viable usage of reduce 😬 returnprices.reduce((total,price)=>total+price,0)/prices.length;}Alternatives considered
Could not find any.
Motivation
Performance
Current behavior
Each time I pass a path it needs to be parsed and the queried for all possible matching items
Desired behavior
Be able to create and object for a path that stores the parsed query and allows me to execute it many times, skipping the overhead of path parsing. Additionally it would be good to specify the search limit.
Example:
Alternatives considered
Could not find any.