diff --git a/calculate/templates/format/json_format.py b/calculate/templates/format/json_format.py index 6a2e010..5724c7c 100644 --- a/calculate/templates/format/json_format.py +++ b/calculate/templates/format/json_format.py @@ -37,11 +37,14 @@ class JSONFormat(Format): '''Метод для получения словаря документа, переопределяющий метод базового класса.''' self._document_dictionary = json.loads(json_file_text, - object_pairs_hook=OrderedDict) + object_pairs_hook=OrderedDict, + encoding="utf8") @property def document_text(self): '''Метод для получения текста документа, переопределяющий метод базового класса.''' - json_file_text = json.dumps(self._document_dictionary, indent=4) - return json_file_text + json_file_text = json.dumps(self._document_dictionary, + ensure_ascii=False, + indent=4).encode('utf8') + return json_file_text.decode() diff --git a/tests/templates/format/test_json.py b/tests/templates/format/test_json.py index d127d76..801b092 100644 --- a/tests/templates/format/test_json.py +++ b/tests/templates/format/test_json.py @@ -106,8 +106,7 @@ class TestParsingMethods: "Description[de]": "Anpassung der Lautstärke von Geräten und Anwendungen", "Description[el]": "Προσαρμογή της έντασης των συσκευών και εφαρμογών", "test": "false" -} -''' +}''' original_object = JSONFormat(original_text, '/path/to/template') template_object = JSONFormat(template_text, '/path/to/template')