CodyKochmann
8/9/2016 - 12:51 AM

Prettyfy (or pretty print) JSON objects in python with this one function. I use this snippet all the time when trying to get a feel for what

Prettyfy (or pretty print) JSON objects in python with this one function. I use this snippet all the time when trying to get a feel for whats happening with the data I'm currently working with.

def prettyfy(input_json, desired_indent=4):
    # returns a prettyfied string of a json object
    # by: codykochmann
    from json import dumps
    return dumps(input_json, sort_keys=True, indent=desired_indent, separators=(',', ': '))