Answer by β.εηοιτ.βε for How to get key and value instead of only value when...
Since you cannot preserve keys in JMESPath when doing an object projection, and that you will have to resort to a loop to have a JSON structure that will allow you to have your desired output see the...
View ArticleAnswer by Vladimir Botka for How to get key and value instead of only value...
Convert the dictionary to the listl1 = [{'key': k, 'value': v} for k, v in s.items()]gives[{'key': '111', 'value': {'name': 'john', 'exp': '1'}}, {'key': '222', 'value': {'name': 'mia', 'exp':...
View ArticleHow to get key and value instead of only value when filtering with JMESPath?
Input data:s = {'111': {'name': 'john', 'exp': '1'}, '222': {'name': 'mia', 'exp': '1'}}Code:import jmespathjmespath.search("(*)[?name=='john']", s)Output:[{'name': 'john', 'exp': '1'}]Output I...
View Article
More Pages to Explore .....