Open wfehr opened 4 years ago
The path id,name,child.[*].id will only return the value of child.[*].id and id,name is ignored.
id,name,child.[*].id
child.[*].id
id,name
Example code to reproduce:
from jsonpath_ng import parse data = {'id': 'foo', 'name': 'Foo', 'child': [{'id': 'child-foo'}]} cases = ( ('id,name', ['foo', 'Foo']), ('id,name,child.[*]', ['foo', 'Foo', {'id': 'child-foo'}]), ('id,name,child.[*].id', ['foo', 'Foo', 'child-foo']), # Error ) for path, expected in cases: actual = [m.value for m in parse(path).find(data)] if expected != actual: print('parser: ' + path) print('actual: ' + str(actual)) print('expected: ' + str(expected)) # prints out: # parser: id,name,child.[*].id # actual: ['child-foo'] # expected: ['foo', 'Foo', 'child-foo']
The path
id,name,child.[*].id
will only return the value ofchild.[*].id
andid,name
is ignored.Example code to reproduce: