# -*- coding: UTF-8 -*-
# 作者：huanhuilong
# 标题：Python with-as 语句(1)
# 描述：文件读写


import json


def load_json(file):
    with open(file, 'r') as f:
        return json.loads(f.read())


def dump_json(file, obj):
    with open(file, 'w') as f:
        f.write(json.dumps(obj, indent=2, ensure_ascii=False))


if __name__ == '__main__':
    data = {
        'test': 1,
    }
    dump_json('test.json', data)
    load_json('test.json')
