npbackup/i18n/loaders/json_loader.py
2023-03-22 00:17:16 +01:00

14 lines
404 B
Python

import json
from . import Loader, I18nFileLoadError
class JsonLoader(Loader):
"""class to load json files"""
def __init__(self):
super(JsonLoader, self).__init__()
def parse_file(self, file_content):
try:
return json.loads(file_content)
except json.JSONDecodeError as e:
raise I18nFileLoadError("invalid JSON: {0}".format(e.args[0])) from e