Browse Source

add ident argument for save_json

quarrying 3 years ago
parent
commit
90d2d3650a
1 changed files with 2 additions and 2 deletions
  1. 2 2
      khandy/utils_file_io.py

+ 2 - 2
khandy/utils_file_io.py

@@ -35,11 +35,11 @@ def load_json(filename, encoding='utf-8'):
     return data
 
 
-def save_json(filename, data, encoding='utf-8', cls=None, sort_keys=False):
+def save_json(filename, data, encoding='utf-8', indent=4, cls=None, sort_keys=False):
     if not filename.endswith('.json'):
         filename = filename + '.json'
     with open(filename, 'w', encoding=encoding) as f:
-        json.dump(data, f, indent=4, separators=(',',': '),
+        json.dump(data, f, indent=indent, separators=(',',': '),
                   ensure_ascii=False, cls=cls, sort_keys=sort_keys)