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

Updating a json object fails if the value of a key is boolean #73

Open
Andrewnopoulos opened this issue Mar 9, 2021 · 0 comments
Open

Comments

@Andrewnopoulos
Copy link

Related to #47

Steps to reproduce:

from jsonpath_ng import parse
selector = '$.*.number'
data = {
    'foo': ['abc', 'def'],
    'bar': {'number': 123456},
    'boolean': True
}
val = '98765'
expr = parse(selector)
expr.update(data, val)

Expected

'number' field to be updated to '98765'.

Observed

  File "/home/andrew/test.py", line 12, in <module>
    expr.update(data, val)
  File "/home/andrew/jsonpath_ng/jsonpath.py", line 261, in update
    self.right.update(datum.value, val)
  File "/home/andrew/jsonpath_ng/jsonpath.py", line 526, in update
    if field in data:
TypeError: argument of type 'bool' is not iterable
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

1 participant