Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

objects must have exactly 1 key defined #29

Open
0019 opened this issue Aug 12, 2022 · 3 comments
Open

objects must have exactly 1 key defined #29

0019 opened this issue Aug 12, 2022 · 3 comments

Comments

@0019
Copy link

0019 commented Aug 12, 2022

I encountered this exception when trying to let JsonLogic return a two-keyed object:

{ "resultType": "statistics", "resultValue": 2 }

Is there any method to return Json object as result? Thanks.

@gdetoni
Copy link

gdetoni commented Jan 29, 2023

I'm seeing the same issue and it makes the Java implementation incompatible with the javascript one.
For instance, the following rule will compute fine in JS but will fail in Java.
{ "if": [ { "==": [ 2, 2 ] }, { "key_1": 0, "key_2": 0 }, { "key_1": null, "key_2": null } ] }

@jamsesso
Copy link
Owner

As a workaround, can you treat your data as a string instead?

For example,

{
  "if": [
    {"==": [2, 2]},
    "{\"key\": \"value1\"}",
    "{\"key\": \"value2\"}"
  ]
}

@cliffamzn
Copy link

I saw a similar result trying to evaluate this rule:

{"and":[{"<":[5,10]},{">":[20,10]},{"==":["ON","ON"]},{">":[43200,36000]},{"<":[43200,68400]}],"or":[{">":[40,10]},{"==":["ON","ON"]}]}

It seems to work fine on the rule evaluator though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants