Title: Contextualized construction does not work · Issue #136 · IBM/JSONata4Java · GitHub
Open Graph Title: Contextualized construction does not work · Issue #136 · IBM/JSONata4Java
X Title: Contextualized construction does not work · Issue #136 · IBM/JSONata4Java
Description: When I contextualize object construction, nothing will be constructed. By "contextualize construction" I mean instead of: { "utter": { "say": nested.greeting, "think": nested.thinking }, "nestedBinding": { "say": $nested.greeting, "think...
Open Graph Description: When I contextualize object construction, nothing will be constructed. By "contextualize construction" I mean instead of: { "utter": { "say": nested.greeting, "think": nested.thinking }, "nestedBin...
X Description: When I contextualize object construction, nothing will be constructed. By "contextualize construction" I mean instead of: { "utter": { "say": nested.greeting, "th...
Opengraph URL: https://github.com/IBM/JSONata4Java/issues/136
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Contextualized construction does not work","articleBody":"When I contextualize object construction, nothing will be constructed.\r\n\r\nBy \"contextualize construction\" I mean instead of: \r\n\r\n```\r\n{ \r\n \"utter\": {\r\n \"say\": nested.greeting,\r\n \"think\": nested.thinking\r\n },\r\n \"nestedBinding\": {\r\n \"say\": $nested.greeting,\r\n \"think\": $nested.thinking\r\n }\r\n}\r\n```\r\n\r\nI want to remove duplication by pulling nested and $nested in front of the object constructor.\r\n\r\n```\r\n{ \r\n \"utter\": nested {\r\n \"say\": greeting,\r\n \"think\": thinking\r\n },\r\n \"nestedBinding\": $nested {\r\n \"say\": greeting,\r\n \"think\": thinking\r\n }\r\n}\r\n```\r\nThis should also allow me to filter for a certain item and then work inside its context, see https://try.jsonata.org/PCo2yBJJg. That way I want to factor out filter criteria for numerous entries.\r\n\r\n```\r\n@Test\r\n public void supportsContextualizedConstruction() throws Exception {\r\n String json = \"{ \\n\" +\r\n \" \\\"nested\\\": {\\n\" +\r\n \" \\\"greeting\\\": \\\"hello\\\",\\n\" +\r\n \" \\\"thinking\\\": \\\"bored\\\"\\n\" +\r\n \" } \\n\" +\r\n \"}\";\r\n JsonNode rootContextNode = JACKSON.readTree(json);\r\n\r\n String jsonata = \"{ \\n\" +\r\n \" \\\"utter\\\": nested {\\n\" +\r\n \" \\\"say\\\": greeting,\\n\" +\r\n \" \\\"think\\\": thinking\\n\" +\r\n \" },\\n\" +\r\n \" \\\"nestedBinding\\\": $nested {\\n\" +\r\n \" \\\"say\\\": greeting,\\n\" +\r\n \" \\\"think\\\": thinking\\n\" +\r\n \" }\\n\"\r\n + \"}\";\r\n Expression jsonataExpr = Expression.jsonata(jsonata);\r\n\r\n ObjectNode bindingNode = JACKSON.createObjectNode();\r\n bindingNode //\r\n .put(\"nested\",\r\n \"{\\n\"\r\n + \" \\\"nested\\\": {\\n\"\r\n + \" \\\"greeting\\\": \\\"welcome\\\",\\n\"\r\n + \" \\\"thinking\\\": \\\"ayaah!\\\" \\n\"\r\n + \" }\\n\"\r\n + \"}\");\r\n\r\n JsonNode transformed = jsonataExpr.evaluate(rootContextNode, bindingNode);\r\n System.out.println(transformed);\r\n }\r\n```\r\nResult:\r\n`{}`\r\n\r\nExpected according to https://try.jsonata.org/Vb34AQ8j4:\r\n```\r\n{\r\n \"utter\": {\r\n \"say\": \"hello\",\r\n \"think\": \"bored\"\r\n },\r\n \"nestedBinding\": {\r\n \"say\": \"welcome\",\r\n \"think\": \"ayaah!\"\r\n }\r\n}\r\n```\r\n","author":{"url":"https://github.com/dschulten","@type":"Person","name":"dschulten"},"datePublished":"2021-01-16T18:05:00.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/136/JSONata4Java/issues/136"}
| 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:5be49aaf-3432-512c-e4e3-80b823a79df5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A41A:397AD8:5F32B24:85C80A0:6A4FFC25 |
| html-safe-nonce | e9ddeb245c34a0f5a1f25b0f44f9bdd8d0e9281c05e5472689ed6aac5a1695cf |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNDFBOjM5N0FEODo1RjMyQjI0Ojg1QzgwQTA6NkE0RkZDMjUiLCJ2aXNpdG9yX2lkIjoiMTY4MDY0NzMxNjMyNTc5MjgwNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a9d0f9d99de256c05d75d17508497430e68cea407f9f6b6774c45c72844ffede |
| hovercard-subject-tag | issue:787521092 |
| 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/IBM/JSONata4Java/136/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ffaa8393d27a00f1c76725515bfcc13c49c9bf2b77a737aadb5cf3ecfb73460e/IBM/JSONata4Java/issues/136 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ffaa8393d27a00f1c76725515bfcc13c49c9bf2b77a737aadb5cf3ecfb73460e/IBM/JSONata4Java/issues/136 |
| og:image:alt | When I contextualize object construction, nothing will be constructed. By "contextualize construction" I mean instead of: { "utter": { "say": nested.greeting, "think": nested.thinking }, "nestedBin... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dschulten |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3bd0ff5d28a87b4801a63fb38c2a21a91b0a700dca159dc9416aeae05771b899 |
| turbo-cache-control | no-preview |
| go-import | github.com/IBM/JSONata4Java git https://github.com/IBM/JSONata4Java.git |
| octolytics-dimension-user_id | 1459110 |
| octolytics-dimension-user_login | IBM |
| octolytics-dimension-repository_id | 169904880 |
| octolytics-dimension-repository_nwo | IBM/JSONata4Java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 169904880 |
| octolytics-dimension-repository_network_root_nwo | IBM/JSONata4Java |
| 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 | 67a336083e4dcb40224dc2c01cd4c7ed413bdb09 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width