Parsing json and searching through it

ObjectPath is a library that provides ability to query JSON and nested structures of dicts and lists. For example, you can search for all attributes called “foo” regardless how deep they are by using $..foo. While the documentation focuses on the command line interface, you can perform the queries programmatically by using the package’s Python … Read more

Disabling sorting mechanism in pprint output

Python 3.8 or newer: Use sort_dicts=False: pprint.pprint(data, sort_dicts=False) Python 3.7 or older: You can monkey patch the pprint module. import pprint pprint.pprint({“def”:2,”ghi”:3,”abc”:1,}) pprint._sorted = lambda x:x # Or, for Python 3.7: # pprint.sorted = lambda x, key=None: x pprint.pprint({“def”:2,”ghi”:3, “abc”:1}) Since the 2nd output is essentiallly randomly sorted, your output may be different from mine: … Read more