Title: Selecting properties containing a square bracket seems to be impossible · Issue #225 · JSONPath-Plus/JSONPath · GitHub
Open Graph Title: Selecting properties containing a square bracket seems to be impossible · Issue #225 · JSONPath-Plus/JSONPath
X Title: Selecting properties containing a square bracket seems to be impossible · Issue #225 · JSONPath-Plus/JSONPath
Description: Describe the bug As far as I can tell (sorry if I'm missing something), it appears to be impossible to select properties that contain a square bracket ([]) in their name. Code sample or steps to reproduce Given the following JSON object:...
Open Graph Description: Describe the bug As far as I can tell (sorry if I'm missing something), it appears to be impossible to select properties that contain a square bracket ([]) in their name. Code sample or steps to re...
X Description: Describe the bug As far as I can tell (sorry if I'm missing something), it appears to be impossible to select properties that contain a square bracket ([]) in their name. Code sample or steps t...
Opengraph URL: https://github.com/JSONPath-Plus/JSONPath/issues/225
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Selecting properties containing a square bracket seems to be impossible","articleBody":"\u003c!--\r\n**PLEASE NOTE: This project is not currently being very actively developed.**\r\n--\u003e\r\n\r\n## Describe the bug\r\n\r\nAs far as I can tell (sorry if I'm missing something), it appears to be impossible to select properties that contain a square bracket (`[]`) in their name.\r\n\r\n## Code sample or steps to reproduce\r\n\r\nGiven the following JSON object:\r\n\r\n```json\r\n{\r\n \"abc\": 2,\r\n \"cd[DataLayer]\": 1\r\n}\r\n```\r\n\r\nI want to select the `cd[DataLayer]` property. These are the expressions I have tried (unsuccessfully):\r\n\r\n```\r\n$[\"cd[DataLayer]\"]\r\n$['cd[DataLayer]']\r\n$.cd[DataLayer]\r\n$.cd`[DataLayer]\r\n$.cd`[DataLayer`]\r\n$['`cd[DataLayer]']\r\n$['cd`[DataLayer]']\r\n$['cd`[DataLayer]`']\r\n$[?(@.property == 'cd[DataLayer]')]\r\n$.cd\\[DataLayer\\]\r\n$.cd.DataLayer\r\n$[`cd[DataLayer]]\r\n$[cd[DataLayer]]\r\n```\r\n\r\n### Console error or logs\r\n\r\nNo errors for any of the expressions listed above, but they all return an empty result (`[]`).\r\n\r\n## Expected behavior\r\n\r\nI would expect there to be some expression that can select the `cd[DataLayer]` property.\r\n\r\nAs per the json-path-comparison project, `$[']']` should return `[42]` for the input `{\"]\": 42}`, which fails in jsonpath-plus: https://cburgmer.github.io/json-path-comparison/results/bracket_notation_with_quoted_closing_bracket_literal.html#JavaScript_jsonpath-plus\r\n\r\n## Expected result\r\n\r\n```json\r\n[\r\n 1\r\n]\r\n```\r\n\r\n## Environment (IMPORTANT)\r\n\r\n- Locally using JSONPath-Plus version: 7.2.0\r\n- And on the [demo page](https://jsonpath-plus.github.io/JSONPath/demo/?)\r\n\r\n## Desktop\r\n\r\n - Firefox 132.0b5 on Ubuntu 24.04.1 LTS\r\n - Node v20.7.0\r\n\r\n","author":{"url":"https://github.com/baltpeter","@type":"Person","name":"baltpeter"},"datePublished":"2024-10-14T14:11:50.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/225/JSONPath/issues/225"}
| 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:a80081da-e720-2295-2790-2d0134fd21ad |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A0D6:2AE7DB:19B46DC:21E5DDF:696EDCC2 |
| html-safe-nonce | 4b6d74210f5e02d3fa46c1d2123f75d3accd0cedde95ba8557bafce2db68da74 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMEQ2OjJBRTdEQjoxOUI0NkRDOjIxRTVEREY6Njk2RURDQzIiLCJ2aXNpdG9yX2lkIjoiNDczNzg3MzMzNjE3Mzc4MDE2MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 11a49c8fa21ccd3ef256c1a21bd2d9ba8f7ed8efaf69d342e4c493b07806b1dd |
| hovercard-subject-tag | issue:2586176574 |
| 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/225/issue_layout |
| twitter:image | https://opengraph.githubassets.com/abbd9e5fad73a18f76764d06510e55d28f7292ce7de314fb7f16933c1a1738a8/JSONPath-Plus/JSONPath/issues/225 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/abbd9e5fad73a18f76764d06510e55d28f7292ce7de314fb7f16933c1a1738a8/JSONPath-Plus/JSONPath/issues/225 |
| og:image:alt | Describe the bug As far as I can tell (sorry if I'm missing something), it appears to be impossible to select properties that contain a square bracket ([]) in their name. Code sample or steps to re... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | baltpeter |
| 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