-
Notifications
You must be signed in to change notification settings - Fork 13
Closed
Description
I can't seem to make a simple query work.
jsonpath2 version
jsonpath2==0.4.1
Platform Details
Mac OS
Steps to Reproduce:
import json
import jsonpath2 as jsonpath
k = {'foo': ['bar', 'baz']}
j = json.dumps(k)
__filter = '$.foo[0]'
print([m.current_value for m in jsonpath.match(__filter, j)])
Output
[jodewey:~/git/ansiblectl] : host-filtering(+25/-2)+* ± python ansiblectl/cmd/test.py
[]
Changing the filter to '$' results in:
['{"foo": ["bar", "baz"]}']
Ultimately I'm trying to simply query a list but nothing seems to work.
import json
import jsonpath2 as jsonpath
k = ['bar', 'baz']
j = json.dumps(k)
__filter = '$[0]'
print([m.current_value for m in jsonpath.match(__filter, j)])
[jodewey:~/git/ansiblectl] : host-filtering(+25/-2)+* ± python ansiblectl/cmd/test.py
[]
These queries work perfectly fine on https://jsonpath.com/
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels