Title: Evaluate also getter from classes · Issue #177 · JSONPath-Plus/JSONPath · GitHub
Open Graph Title: Evaluate also getter from classes · Issue #177 · JSONPath-Plus/JSONPath
X Title: Evaluate also getter from classes · Issue #177 · JSONPath-Plus/JSONPath
Description: Could be related to #174 Motivation Currently the getter from classes, that encapsulate fields, are not "visible" to the library, so it is not possible to get a value from getter property. Becase getter are "seen" from developer as reado...
Open Graph Description: Could be related to #174 Motivation Currently the getter from classes, that encapsulate fields, are not "visible" to the library, so it is not possible to get a value from getter property. Becase g...
X Description: Could be related to #174 Motivation Currently the getter from classes, that encapsulate fields, are not "visible" to the library, so it is not possible to get a value from getter property...
Opengraph URL: https://github.com/JSONPath-Plus/JSONPath/issues/177
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Evaluate also getter from classes","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\nCould be related to https://github.com/JSONPath-Plus/JSONPath/issues/174\r\n\r\n## Motivation\r\n\r\n\u003c!-- What would be the purpose of this new feature? --\u003e\r\n\r\nCurrently the `getter` from classes, that encapsulate fields, are not \"visible\" to the library, so it is not possible to get a value from getter property. Becase getter are \"seen\" from developer as readonly fields, the library should at least also be able to \"read\" them.\r\n\r\n## Current behavior\r\n\r\n\u003c!-- If this is to enhance an existing rule, how does the rule\r\n currently behave in regard to the new changes? --\u003e\r\n\r\ngetter are ignored\r\n\r\n## Desired behavior\r\n\r\n\u003c!-- What would you like to see happen instead? --\u003e\r\n\r\nThe getters should be evaluated exactly the same as pure fields in classes.\r\n\r\n## Code example\r\n\r\n```js\r\nimport { JSONPath } from 'jsonpath-plus';\r\n\r\nclass TestData {\r\n #value;\r\n \r\n constructor(value) {\r\n this.#value = value;\r\n }\r\n\r\n get value() {\r\n return this.#value;\r\n }\r\n\r\n toJSON() {\r\n return { jsonValue: this.value };\r\n }\r\n\r\n someValue = 33;\r\n}\r\n\r\nconst data = new TestData(11);\r\nconsole.log(data); // TestData {someValue: 33}\r\nconsole.log(data.value); // 11\r\nconsole.log(data['value']); // 11\r\nconsole.log(JSON.stringify(data)); // {\"jsonValue\":11}\r\n\r\nconst val = JSONPath({ path: '$.value', json: data });\r\nconst val1 = JSONPath({ path: '$.jsonValue', json: data });\r\nconst val2 = JSONPath({ path: '$.#value', json: data });\r\nconst val3 = JSONPath({ path: '$.someValue', json: data });\r\n\r\nconsole.log(val); // [] - expected [11]\r\nconsole.log(val1); // []\r\nconsole.log(val2); // []\r\nconsole.log(val3); // [33]\r\n\r\nconsole.log(Object.prototype.hasOwnProperty.call(data, 'value')); // false\r\nconsole.log('value' in data); // true\r\n```\r\n","author":{"url":"https://github.com/WebDucer","@type":"Person","name":"WebDucer"},"datePublished":"2022-08-19T14:15:06.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/177/JSONPath/issues/177"}
| 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:eb9361f2-dd87-e0d3-4a0c-41235742df7a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E9C8:3BB1CB:107E7D9:1743E3F:696F55AF |
| html-safe-nonce | 1656449fe8e0c1c1871c95849ec60421aa6df7a031b40bde3fad512d6a5d420b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOUM4OjNCQjFDQjoxMDdFN0Q5OjE3NDNFM0Y6Njk2RjU1QUYiLCJ2aXNpdG9yX2lkIjoiNjk3NjcwNjM5NzgwNzE0NzEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 86e5943d016ef1f6f27db9c078d804b28b4760635a87c4ab12a41f6a12eb3411 |
| hovercard-subject-tag | issue:1344503802 |
| 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/177/issue_layout |
| twitter:image | https://opengraph.githubassets.com/96483ebd895c4c276dc86bf28da031aba87d2eb7fe5864d48a5c54de2c4b8d16/JSONPath-Plus/JSONPath/issues/177 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/96483ebd895c4c276dc86bf28da031aba87d2eb7fe5864d48a5c54de2c4b8d16/JSONPath-Plus/JSONPath/issues/177 |
| og:image:alt | Could be related to #174 Motivation Currently the getter from classes, that encapsulate fields, are not "visible" to the library, so it is not possible to get a value from getter property. Becase g... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | WebDucer |
| hostname | github.com |
| expected-hostname | github.com |
| None | 49bb2ee76ae1b4ec758faefafda636ff20b05a9708bb290d28422cdf542ae979 |
| 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 | 036f37fe552777ac9c6ee661957f947285aab936 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width