18 lines
407 B
Python
18 lines
407 B
Python
__author__ = 'stubbfel'
|
|
import json
|
|
import utilities.textfileutility as tfu
|
|
|
|
def write_json(filename, json_object):
|
|
|
|
valid_types = (dict, str)
|
|
if not isinstance(json_object, valid_types):
|
|
raise ValueError
|
|
|
|
if isinstance(json_object, str):
|
|
json_object = json.loads(json_object)
|
|
|
|
json_string = json.dumps(json_object, indent=4)
|
|
tfu.write_text_file(filename, json_string)
|
|
|
|
|