jmespath

Return integer or string instead of None from a JMESPath query

Return integer or string instead of None from a JMESPath query Question: Is there a way to return an integer or a string instead of None? I know that I can do an additional check like: item = {"SX": {"BX": 1}} value = jmespath.search("SX.BX", item) if jmespath.search("SX.BX", item) else 0 but the condition is very …

Total answers: 1

How can I get all data from JSON using JMESPath

How can I get all data from JSON using JMESPath Question: I am trying to get all the data with the attribute _name equal to accountId. I have managed to do it almost fine, the only issue is that from times to times times I have an object. with two _name attributes with the value …

Total answers: 1

Xpath like query for nested python dictionaries

Xpath like query for nested python dictionaries Question: Is there a way to define a XPath type query for nested python dictionaries. Something like this: foo = { ‘spam’:’eggs’, ‘morefoo’: { ‘bar’:’soap’, ‘morebar’: {‘bacon’ : ‘foobar’} } } print( foo.select(“/morefoo/morebar”) ) >> {‘bacon’ : ‘foobar’} I also needed to select nested lists 😉 This can …

Total answers: 11