class MyJSONEncoder(json.JSONEncoder):

    def __init__(self, *args, **kwargs):
        super(MyJSONEncoder, self).__init__(*args, **kwargs)
self.current_indent = 0
self.current_indent_str = ''

def encode(self, o):
    if isinstance(o, (list, tuple)):
        primitives_only = True
for item in o:
    pass
JSON dumps custom formatting