python-rule-engine icon indicating copy to clipboard operation
python-rule-engine copied to clipboard

Have you considered using jsonata?

Open iiian opened this issue 5 months ago • 1 comments

You might be able to escape some of the weight of carrying around everything in JSON by transitioning to jsonata.

In your example, you use

rule = {
    "name": "basic_rule",
    "conditions": {
        "all": [
            {
                # JSONPath support
                "path": "$.person.name",
                "operator": "equal",
                "value": "Lionel"
            },
            {
                "path": "$.person.last_name",
                "operator": "equal",
                "value": "Messi"
            }
        ]
    }
}

if you were to use the jsonata-python project as part of your engine, you could reduce these to

rule = {
  "name": "basic_rule",
  "conditions": {
    "all": [
      "$.person.name == \"Lionel\",
      "$.person.last_name == \"Messi\""
    ]
  }

or even

rule = {
  "name": ...
  "conditions": "$.person.name == \"Lionel\" and $.person.last_name == \"Messi\""
}

Feel free to close this issue, as it's completely unsolicited input.

iiian avatar Aug 31 '25 16:08 iiian

Hi! Sorry for the late reply. That library looks incredible I did not know something like that existed. Im definitely gonna look into it.

santalvarez avatar Sep 17 '25 12:09 santalvarez