Fix compacting large json files

This commit is contained in:
shortcutme 2019-10-06 03:10:20 +02:00
parent 119e1a9bf0
commit 917a2e59ce
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE

View file

@ -49,7 +49,7 @@ def jsonDumps(data):
else:
return match.group(0)
content = re.sub(r"\{(\n[^,\[\{]{10,100}?)\}[, ]{0,2}\n", compact_dict, content, flags=re.DOTALL)
content = re.sub(r"\{(\n[^,\[\{]{10,100000}?)\}[, ]{0,2}\n", compact_dict, content, flags=re.DOTALL)
def compact_list(match):
if "\n" in match.group(0):
@ -58,7 +58,7 @@ def jsonDumps(data):
else:
return match.group(0)
content = re.sub(r"\[([^\[\{]{2,300}?)\][, ]{0,2}\n", compact_list, content, flags=re.DOTALL)
content = re.sub(r"\[([^\[\{]{2,100000}?)\][, ]{0,2}\n", compact_list, content, flags=re.DOTALL)
# Remove end of line whitespace
content = re.sub(r"(?m)[ ]+$", "", content)