commented out iterencode function within MyJsonEncoder as it reformated the json as a single line and made it hard to read
This commit is contained in:
+15
-15
@@ -47,21 +47,21 @@ class MyJsonEncoder(json.JSONEncoder):
|
||||
return repr(obj)
|
||||
return json.JSONEncoder.default(self, obj)
|
||||
|
||||
def iterencode(self, o, _one_shot=False):
|
||||
list_lvl = 0
|
||||
l=super().iterencode(o, _one_shot=_one_shot)
|
||||
#l=tuple(l);print(''.join(l)) # helpful to debug
|
||||
for s in l:
|
||||
if s.startswith('['):
|
||||
list_lvl += 1
|
||||
if list_lvl > 0:
|
||||
s = s[0]+s[1:].replace('\n', '').strip()
|
||||
s = s.replace('\n', '').rstrip()
|
||||
#self.item_separator):
|
||||
#self.key_separator
|
||||
if s.endswith(']'):
|
||||
list_lvl -= 1
|
||||
yield s
|
||||
# def iterencode(self, o, _one_shot=False):
|
||||
# list_lvl = 0
|
||||
# l=super().iterencode(o, _one_shot=_one_shot)
|
||||
# #l=tuple(l);print(''.join(l)) # helpful to debug
|
||||
# for s in l:
|
||||
# if s.startswith('['):
|
||||
# list_lvl += 1
|
||||
# if list_lvl > 0:
|
||||
# s = s[0]+s[1:].replace('\n', '').strip()
|
||||
# s = s.replace('\n', '').rstrip()
|
||||
# #self.item_separator):
|
||||
# #self.key_separator
|
||||
# if s.endswith(']'):
|
||||
# list_lvl -= 1
|
||||
# yield s
|
||||
|
||||
def MyJsonDecoder(dct):
|
||||
if isinstance(dct, dict):
|
||||
|
||||
Reference in New Issue
Block a user