h2non / jsonpath-ng

Finally, a JSONPath implementation for Python that aims to be standard compliant. That's all. Enjoy!
Apache License 2.0
593 stars 86 forks source link

$..* does not return array elements as expected #164

Open gerrycampion opened 8 months ago

gerrycampion commented 8 months ago

The following code:

from jsonpath_ng import parse
jsonpath_expr = parse('$..*')
[f"{match.path}" for match in jsonpath_expr.find({"list":[{"prop1":"val1"},{"prop2":"val2"}]})]

returns a list with 3 items:

['list', 'prop1', 'prop2']

I would expect it to return 5 items something like:

['list', '[0]', 'prop1', '[1]', 'prop2']

It is returning the array, and the values within the properties within objects within the array, but not the objects themselves.

The specification article says "all Elements in XML document. All members of JSON structure."

Other implementations return 5 items as well.

nitoygo commented 1 week ago

This should be fixed by using the ext right?

from jsonpath_ng.ext import parse
gerrycampion commented 5 days ago

This should be fixed by using the ext right?

from jsonpath_ng.ext import parse

I just tried this and still got the same result.