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

Wrong datum and value returned by find method #96

Open
M-Ghasemi opened this issue Dec 27, 2021 · 0 comments
Open

Wrong datum and value returned by find method #96

M-Ghasemi opened this issue Dec 27, 2021 · 0 comments
Labels

Comments

@M-Ghasemi
Copy link

I think a.[0].[0] and a.[1].[0] should not be part of the results and their value should not be as it is.

import jsonpath_ng
print('VERSION: ' + jsonpath_ng.__version__)
data = {'a': ['foo', 'bar']}
for datum in jsonpath_ng.parse('$..[*]').find(data):
    print(f"\npath: {datum.full_path} | value: {datum.value}")
    
    try:
        equivalent_datum = jsonpath_ng.parse(str(datum.full_path)).find(data)[0]
        if equivalent_datum.value != datum.value:
            print(f"THE CORRECT VALUE IS: {equivalent_datum.value}")
    except KeyError:
        pass
VERSION: 1.5.3

path: [0] | value: {'a': ['foo', 'bar']}

path: a.[0] | value: foo

path: a.[1] | value: bar

path: a.[0].[0] | value: foo
THE CORRECT VALUE IS: f

path: a.[1].[0] | value: bar
THE CORRECT VALUE IS: b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants