Skip to content

Bindings error in expression.evaluate() method #16

Closed
@tokebe

Description

@tokebe

Thanks for writing this package! It shocks me that jsonata isn't more popular.

Bindings appear to be broken in the evaluate method, minimal example:

import jsonata
expr = jsonata.Jsonata("$ & $test_value")
expr.evaluate("a string!", {"test_value": "test"})

Produces error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jcallaghan/.pyenv/versions/3.11.10/lib/python3.11/site-packages/jsonata/jsonata.py", line 1947, in evaluate
    for k, v in bindings.bindings.items():
                ^^^^^^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'bindings'

However, expression.assign() still seems to work:

import jsonata
expr = jsonata.Jsonata("$ & $test_value")
expr.assign("test_value", "test")
print(expr.evaluate("a string!"))

Outputs as expected:

a string!test

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions