jsonUtil.py 503 B

1234567891011121314151617181920
  1. # utils/jsonUtil.py
  2. import json
  3. class JsonUtil:
  4. @staticmethod
  5. def load_json(file_path):
  6. with open(file_path, 'r') as file:
  7. return json.load(file)
  8. @staticmethod
  9. def dump_json(data, file_path):
  10. with open(file_path, 'w') as file:
  11. json.dump(data, file)
  12. @staticmethod
  13. def read_json(file_path):
  14. """读取JSON文件内容"""
  15. with open(file_path, 'r', encoding='utf-8') as f:
  16. return json.load(f)