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

Can I provide in clause in json like facts.get('value') in ('a', 'b', 'c', d') #414

Open
naveenirukulapati opened this issue Apr 26, 2023 · 1 comment

Comments

@naveenirukulapati
Copy link

Hi, I am doing a poc to use Easy rules by defining rules in a json file. My question is can I define in condition in json as provided below.

[
{
"name": "TestRule",
"description": "Test rule",
"condition": "facts.get('value') in [9, 10]",
"actions": ["System.out.println("Passed");"]
}
]

Currently I am getting an exception

java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.lang.Boolean (java.lang.Integer and java.lang.Boolean are in module java.base of loader 'bootstrap')
at org.jeasy.rules.mvel.MVELCondition.evaluate(MVELCondition.java:65)
at org.jeasy.rules.mvel.MVELRule.evaluate(MVELRule.java:120)
at org.jeasy.rules.core.DefaultRulesEngine.doFire(DefaultRulesEngine.java:97)
at org.jeasy.rules.core.DefaultRulesEngine.fire(DefaultRulesEngine.java:70)
at com.wayfair.my.java.project.service.EasyRylesService.runEasyRulesEngine(EasyRylesService.java:53)
at com.wayfair.my.java.project.service.EasyRylesService.main(EasyRylesService.java:31)

Thanks in advance for the help.

@zhhaojie
Copy link
Contributor

zhhaojie commented Oct 19, 2023

That's because you provided illegal JSON data. It has nothing to do with easyRuleEngine. It doesn't need to care about how you store your rules.

[
    {
        "name": "TestRule",
        "description": "Test rule",
        "condition": "facts.get('value') in [9, 10]",
        "actions": [
            {
                "ACTION1": "DO ONE"
            },
            {
                "ACTION2": "DO TWO"
            }
        ]
    }
]

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

No branches or pull requests

2 participants