You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: