Title: Performance improvements · Issue #220 · JSONPath-Plus/JSONPath · GitHub
Open Graph Title: Performance improvements · Issue #220 · JSONPath-Plus/JSONPath
X Title: Performance improvements · Issue #220 · JSONPath-Plus/JSONPath
Description: 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 ...
Open Graph Description: 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 s...
X Description: 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 s...
Opengraph URL: https://github.com/JSONPath-Plus/JSONPath/issues/220
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Performance improvements","articleBody":"\u003c!--\r\nNOTE: THIS PROJECT IS NOT BEING ACTIVELY MAINTAINED.\r\n\r\nYou can file a suggestion in case someone decides to work on it.\r\n\r\nHowever, any proposed syntax changes will most likely be required to\r\nfirst go through standardization for consistency with other jsonpath\r\nimplementatioins.\r\n\r\nSee https://github.com/JSONPath-Plus/JSONPath/issues/124 .\r\n--\u003e\r\n\r\n## Motivation\r\n\r\nPerformance\r\n\r\n## Current behavior\r\n\r\nEach time I pass a path it needs to be parsed and the queried for all possible matching items\r\n\r\n## Desired behavior\r\n\r\nBe 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.\r\n\r\nExample:\r\n```ts\r\nconst bookTitlePath = new JSONPath\u003cstring\u003e('$..book[*].title');\r\nconst bookPricePath = new JSONPath\u003cnumber\u003e('$..book[*].price');\r\n\r\nfunction getFirstBook(storeData: object): string {\r\n return bookTitlePath.value(storeData); // Returns first match\r\n}\r\n\r\n// Consider books are in desc order of sales\r\nfunction getAveragePriceOfBestSellingBooks(storeData: object): number {\r\n const prices: number[] = bookPricePath.query(storeData, 10); // Get up to 10 elements\r\n\r\n // The only viable usage of reduce 😬 \r\n return prices.reduce((total, price) =\u003e total + price, 0) / prices.length;\r\n}\r\n```\r\n\r\n## Alternatives considered\r\n\r\nCould not find any.","author":{"url":"https://github.com/romulof","@type":"Person","name":"romulof"},"datePublished":"2024-10-02T09:00:54.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/220/JSONPath/issues/220"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:76cc5dd5-87c0-be19-2d68-43b61cfaca47 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ED32:CFFA:13B1F6:190C14:696EDCF5 |
| html-safe-nonce | 928d209d124af840df8cdd07e36be23b1328cc52f888bcecca800d2060f8a972 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFRDMyOkNGRkE6MTNCMUY2OjE5MEMxNDo2OTZFRENGNSIsInZpc2l0b3JfaWQiOiIzMTY5OTU0Njg4MjE5OTI5ODQ1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | dee864e658e26e93e2161267ff4038177f85146862f98065e1d637f088afee18 |
| hovercard-subject-tag | issue:2561018355 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/JSONPath-Plus/JSONPath/220/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a9d658cf935bcaa835c3810b7995008e4376e5a3e5064a236ea0f00078c5bbb9/JSONPath-Plus/JSONPath/issues/220 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a9d658cf935bcaa835c3810b7995008e4376e5a3e5064a236ea0f00078c5bbb9/JSONPath-Plus/JSONPath/issues/220 |
| og:image:alt | 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 s... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | romulof |
| hostname | github.com |
| expected-hostname | github.com |
| None | b278ad162d35332b6de714dfb005de04386c4d92df6475522bef910f491a35ee |
| turbo-cache-control | no-preview |
| go-import | github.com/JSONPath-Plus/JSONPath git https://github.com/JSONPath-Plus/JSONPath.git |
| octolytics-dimension-user_id | 67874603 |
| octolytics-dimension-user_login | JSONPath-Plus |
| octolytics-dimension-repository_id | 1716525 |
| octolytics-dimension-repository_nwo | JSONPath-Plus/JSONPath |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1716525 |
| octolytics-dimension-repository_network_root_nwo | JSONPath-Plus/JSONPath |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 39aed5006635ab6f45e6b77d23e73b08a00272a3 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width