-
Notifications
You must be signed in to change notification settings - Fork 52
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
Is there a way to get the map result with 'relative path' like *..c ? #74
Comments
This works for the example you've given...
|
Thanks for answering, but the relative path means that I don't know how many blocks in the given nested dict, so I wonder if there is a way to do like the objectpath do. import objectpath
raw = {
"args": {},
"headers": {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate",
"Host": "httpbin.org",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36",
"X-Amzn-Trace-Id": "Root=1-5e67a051-171e2874180dc5964fb7884d"
},
"origin": "47.104.199.113",
"url": "http://httpbin.org/get"
}
tree = objectpath.Tree(raw)
result = [i for i in tree.execute('$..Accept')]
print(result)
# ['*/*'] |
Ah, I see. As far as I know, recursive descent is not possible in JMESPath |
Yes, I read the doc/source code in a while but not found that feature, so it may not be the purpose of JMESPath. JMESPath is very fast, and the implementation didn't contains a recursive parsing usage, this issue is just want to ensure that. Close issue, thank all the same. |
@ClericPy We want to propose this feature to JMESPath and will include this in the next iteration for JMESPath Community. |
input:
{"a": {"b": {"c": {"d": "value"}}}}
path:
*..c
expect:
{"d": "value"}
The text was updated successfully, but these errors were encountered: