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

update_or_create fails when root object of original object is a list #108

Open
rolling-robot opened this issue Jun 22, 2022 · 0 comments
Open

Comments

@rolling-robot
Copy link

Root object and first path element are inconsistent, yet update_or_create returns (and modifies original object!)

> pp = jsonpath_ng.ext.parse('$[0].section')
> pp.update_or_create({}, 1)
[{'section': 1}]

Now I'm asking jsonpath_ng to change the previous value to 2, but I get an error:

> pp.update_or_create([{'section': 1}], 2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/pete/.pyenv/versions/3.9.9/lib/python3.9/site-packages/jsonpath_ng/jsonpath.py", line 289, in update_or_create
    return _clean_list_keys(data)
  File "/home/pete/.pyenv/versions/3.9.9/lib/python3.9/site-packages/jsonpath_ng/jsonpath.py", line 763, in _clean_list_keys
    for key, value in dict_.items():
AttributeError: 'list' object has no attribute 'items'

Seems like a bug in handling first path element.

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