Title: continue to deal the result as a array after filter · Issue #202 · JSONPath-Plus/JSONPath · GitHub
Open Graph Title: continue to deal the result as a array after filter · Issue #202 · JSONPath-Plus/JSONPath
X Title: continue to deal the result as a array after filter · Issue #202 · JSONPath-Plus/JSONPath
Description: Motivation I have a json like this: { "contactMedium": [ { "@type": "EmailContactMedium", "preferred": true, "contactType": "other", "validFor": { "startDateTime": "2018-10-22T08:31:52.028Z" }, "emailAddress": "tom@email.com" }, { "@type...
Open Graph Description: Motivation I have a json like this: { "contactMedium": [ { "@type": "EmailContactMedium", "preferred": true, "contactType": "other", "validFor": { "startDateTime": "2018-10-22T08:31:52.028Z" }, "em...
X Description: Motivation I have a json like this: { "contactMedium": [ { "@type": "EmailContactMedium", "preferred": true, "contactType": "other", &quo...
Opengraph URL: https://github.com/JSONPath-Plus/JSONPath/issues/202
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"continue to deal the result as a array after filter","articleBody":"## Motivation\r\nI have a json like this:\r\n```\r\n{\r\n \"contactMedium\": [\r\n {\r\n \"@type\": \"EmailContactMedium\",\r\n \"preferred\": true,\r\n \"contactType\": \"other\",\r\n \"validFor\": {\r\n \"startDateTime\": \"2018-10-22T08:31:52.028Z\"\r\n },\r\n \"emailAddress\": \"tom@email.com\"\r\n },\r\n {\r\n \"@type\": \"GeographicAddressContactMedium\",\r\n \"preferred\": true,\r\n \"contactType\": \"other\",\r\n \"validFor\": {\r\n \"startDateTime\": \"2018-10-22T08:31:52.028Z\"\r\n },\r\n }\r\n ]\r\n}\r\n```\r\nI want to get the number of item with preferred==true\r\nconst result = JSONPath({ path: '$.contactMedium[?(@.preferred==true)].length', json: data })\r\n## Current behavior\r\ngot []\r\n## Desired behavior\r\ngot 2\r\n## Alternatives considered\r\ncurrently, i can got the result expected by this way.\r\nconst result = JSONPath({ path: '$.contactMedium[?(@.preferred==true)]', json: data })\r\nconsole.log(result)\r\n\r\nconst result2 = JSONPath({ path: '$.length', json: result })\r\nconsole.log(result2)","author":{"url":"https://github.com/NingGelin","@type":"Person","name":"NingGelin"},"datePublished":"2024-01-15T06:05:26.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/202/JSONPath/issues/202"}
| 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:f2831b68-6b0a-2548-fdf2-c46359427305 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8A24:FDA3:26D48F7:33C8279:696EFDDD |
| html-safe-nonce | e339b26eb71534b58d55f7d35994e1b2bb7fb040497a993ef08d7e66434890b1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QTI0OkZEQTM6MjZENDhGNzozM0M4Mjc5OjY5NkVGREREIiwidmlzaXRvcl9pZCI6IjgzMzEzMDAzOTc5MDczMDcxNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d7af59de5b47eaf29af700bce601019d32770abb8d9c75c5fa23feaf5464b92c |
| hovercard-subject-tag | issue:2081312412 |
| 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/202/issue_layout |
| twitter:image | https://opengraph.githubassets.com/49c5e759a6b9a99b624b89853e27b7ac3660a0b5f0eaee3996cb7c00029881ec/JSONPath-Plus/JSONPath/issues/202 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/49c5e759a6b9a99b624b89853e27b7ac3660a0b5f0eaee3996cb7c00029881ec/JSONPath-Plus/JSONPath/issues/202 |
| og:image:alt | Motivation I have a json like this: { "contactMedium": [ { "@type": "EmailContactMedium", "preferred": true, "contactType": "other", "validFor": { "startDateTime": "2018-10-22T08:31:52.028Z" }, "em... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | NingGelin |
| 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