jmespath / jmespath/jmespath.py
Unable to parse index expressions
- Dominant language
- Python
- Stars
- 2.4k
- Forks
- 212
- PR merge metrics
- No merged PRs in 30d
Description
Using jmespath.py 0.9.3 on Python 3.6.5 I have trouble performing some expressions.
E.g. using this JSON fake data from json-server
`json_data = '[{"id":0,"name":"Fabian Kautzer","avatar":"https://s3.amazonaws.com/uifaces/faces/twitter/anaami/128.jpg","email":"Shaun_Hoppe@hotmail.com","company":"Hessel Group","address":{"zip":"14902","city":"Jonesfort","streetName":"Padberg Groves","streetAddress":"718 Veum Flat","state":"Hawaii"}},{"id":1,"name":"Dr. Alysha Carroll","avatar":"https://s3.amazonaws.com/uifaces/faces/twitter/ssbb_me/128.jpg","email":"Elva52@hotmail.com","company":"Tromp - Mann","address":{"zip":"14233","city":"Watersport","streetName":"Kyleigh Tunnel","streetAddress":"2825 Kuvalis Forges","state":"Oklahoma"}},{"id":2,"name":"Vilma Littel","avatar":"https://s3.amazonaws.com/uifaces/faces/twitter/pcridesagain/128.jpg","email":"Garnett_Purdy@hotmail.com","company":"Mills, Langworth and Herman","address":{"zip":"15174","city":"Noemieland","streetName":"Halvorson Stream","streetAddress":"040 Parker Mission","state":"Wisconsin"}},{"id":3,"name":"Lyda Quigley","avatar":"https://s3.amazonaws.com/uifaces/faces/twitter/kolmarlopez/128.jpg","email":"Craig.Kunde98@gmail.com","company":"Altenwerth Inc","address":{"zip":"74175-8542","city":"North Godfrey","streetName":"Schultz Crossing","streetAddress":"09983 Hermann Crest","state":"Tennessee"}}]'
`
I'm unable to perform single element selection using something like this:
`parsed: jmespath.parser.ParsedResult = jmespath.search("[0].name", json_data)`
This will return `None` when printed using `print(parsed)`. Notice that in general jmespath seems to work since I will get the correct result (current node) when executing this:
`parsed: jmespath.parser.ParsedResult = jmespath.search("@", json_data)`
I tried using the same JSON data and jmespath expression in the online examples engine at http://jmespath.org/examples.html and it works just fine there. Thus either this is a bug or I'm using this Python lib incorrectly. Would be awesome if you could help.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.