Title: $match does not match function signature occurs when passing arguments without chaining · Issue #291 · IBM/JSONata4Java · GitHub
Open Graph Title: $match does not match function signature occurs when passing arguments without chaining · Issue #291 · IBM/JSONata4Java
X Title: $match does not match function signature occurs when passing arguments without chaining · Issue #291 · IBM/JSONata4Java
Description: Sample code showing error Running a simple code where a function is applied to the output of a $match expression Expressions parse = Expressions.parse("$number($match($.a, /(\\d+)/).groups[0]))"); JsonNode inputNode = new ObjectMapper()....
Open Graph Description: Sample code showing error Running a simple code where a function is applied to the output of a $match expression Expressions parse = Expressions.parse("$number($match($.a, /(\\d+)/).groups[0]))"); ...
X Description: Sample code showing error Running a simple code where a function is applied to the output of a $match expression Expressions parse = Expressions.parse("$number($match($.a, /(\\d+)/).groups[0])...
Opengraph URL: https://github.com/IBM/JSONata4Java/issues/291
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"$match does not match function signature occurs when passing arguments without chaining","articleBody":"**Sample code showing error**\r\nRunning a simple code where a function is applied to the output of a `$match` expression\r\n```\r\nExpressions parse = Expressions.parse(\"$number($match($.a, /(\\\\d+)/).groups[0]))\");\r\nJsonNode inputNode = new ObjectMapper().readTree(\"{\\\"a\\\" : \\\"001\\\"}\");\r\n```\r\n\r\nResults in an error from `$match`\r\n```\r\ncom.api.jsonata4java.expressions.EvaluateException: Argument 1 of function $match does not match function signature\r\njava.lang.RuntimeException: com.api.jsonata4java.expressions.EvaluateException: Argument 1 of function $match does not match function signature\r\n\t...\r\nCaused by: com.api.jsonata4java.expressions.EvaluateRuntimeException: Argument 1 of function $match does not match function signature\r\n\tat app//com.api.jsonata4java.expressions.functions.MatchFunction.invoke(MatchFunction.java:99)\r\n\tat app//com.api.jsonata4java.expressions.ExpressionsVisitor.visitFunction_call(ExpressionsVisitor.java:1823)\r\n\tat \r\n```\r\n\r\n**Native Jsonata Works**\r\nThe same input/output works just in Try Jsonata regardless of jsonata version\r\nhttps://try.jsonata.org/y5CkUaJVY\r\n\r\n**Issue code**\r\nThe inconsistency appears to be in [FunctionUtils](https://github.com/IBM/JSONata4Java/blob/3c9604e8105a589e0244c05bb2a5d674c6842124/src/main/java/com/api/jsonata4java/expressions/utils/FunctionUtils.java#L902) where the function is choosing to use the context despite it not being a valid input and having enough arguments already.\r\n```\r\nif (signature.indexOf(\"-\") \u003e= 0 \u0026\u0026 prc != null \u0026\u0026 prc instanceof PathContext) {\r\n return true;\r\n}\r\n```\r\n\r\n\r\n**Workaround**\r\nSwapping around the code so the string is actually used as the context will work\r\n`\"$.a.$match(/(\\\\d+)/).groups[0] ~\u003e $number()\"`","author":{"url":"https://github.com/lo-jason","@type":"Person","name":"lo-jason"},"datePublished":"2023-11-27T18:02:54.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/291/JSONata4Java/issues/291"}
| 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:a2cc7295-0fbe-a919-c1b9-4ead96066cb6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C0AE:2E1FD9:1509D5E:1D5DA06:6A4DF4CB |
| html-safe-nonce | 0cc7197d51317c8130b6daf43e57f47c929cb52afd2bdd6e0c97a81e40556b4e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMEFFOjJFMUZEOToxNTA5RDVFOjFENURBMDY6NkE0REY0Q0IiLCJ2aXNpdG9yX2lkIjoiNDEzODQ0MDIyNTQ1Mjg0ODMzMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | b0d39df4158e0aff046c43807be16c99d43c4bbfab1970b12c99679d093b9d3c |
| hovercard-subject-tag | issue:2012814203 |
| 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/291/issue_layout |
| twitter:image | https://opengraph.githubassets.com/90e839cb255715cb4fc2ca33a0c2193b091fd2a7c377320a5d118b7529cd78ab/IBM/JSONata4Java/issues/291 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/90e839cb255715cb4fc2ca33a0c2193b091fd2a7c377320a5d118b7529cd78ab/IBM/JSONata4Java/issues/291 |
| og:image:alt | Sample code showing error Running a simple code where a function is applied to the output of a $match expression Expressions parse = Expressions.parse("$number($match($.a, /(\\d+)/).groups[0]))"); ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | lo-jason |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5818716c93c6a2925b815402541a32814e43a7b1261c322b0c2df75224289566 |
| 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 | f4bb89367ca678f057d79b1abc45d6675b1bd5b2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width