aboutsummaryrefslogtreecommitdiffstats
path: root/config_file/json_parser.py
diff options
context:
space:
mode:
Diffstat (limited to 'config_file/json_parser.py')
-rw-r--r--config_file/json_parser.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/config_file/json_parser.py b/config_file/json_parser.py
index 5314cd7..58924b4 100644
--- a/config_file/json_parser.py
+++ b/config_file/json_parser.py
@@ -1,15 +1,19 @@
import json
+from typing import Type
from .base_parser import BaseParser
class JsonParser(BaseParser):
def __init__(self, file_contents: str):
- super().__init__(
- file_contents=file_contents,
- module=json,
- decode_error=json.decoder.JSONDecodeError,
- )
-
- def stringify(self) -> str:
- return json.dumps(self.parsed_content, indent=4)
+ super().__init__(file_contents)
+
+ @property
+ def decode_error(self) -> Type[Exception]:
+ return json.decoder.JSONDecodeError
+
+ def loads(self, contents: str) -> dict:
+ return json.loads(contents)
+
+ def dumps(self, loaded_contents: dict) -> str:
+ return json.dumps(loaded_contents, indent=4)