Skip to content
Snippets Groups Projects
Commit b81d3b98 authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

fixed a bug that disabled json if ujson was not installed

parent e1204710
No related branches found
No related tags found
No related merge requests found
# v2.15.7 # v2.15.7
* deprecated `IteratorListAdapter` * deprecated `IteratorListAdapter`
* fixed a bug that disabled json if ujson was not installed
__version__ = '2.15.7a2' __version__ = '2.15.7a3'
...@@ -76,8 +76,9 @@ def write_json_to_file(path: str, value: JSONAble) -> None: ...@@ -76,8 +76,9 @@ def write_json_to_file(path: str, value: JSONAble) -> None:
value = value.to_json() value = value.to_json()
with open(path, 'w') as f_out: with open(path, 'w') as f_out:
try: try:
import ujson
ujson.dump(value, f_out) ujson.dump(value, f_out)
except NameError: except ImportError:
json.dump(value, f_out) json.dump(value, f_out)
...@@ -113,9 +114,10 @@ def read_json_from_file(path: str) -> JSONAble: ...@@ -113,9 +114,10 @@ def read_json_from_file(path: str) -> JSONAble:
:raises OSError: the file was not readable or did not exist :raises OSError: the file was not readable or did not exist
""" """
try: try:
import ujson
with open(path, 'r') as f_in: with open(path, 'r') as f_in:
return ujson.load(f_in) return ujson.load(f_in)
except NameError: except ImportError:
with open(path, 'r') as f_in: with open(path, 'r') as f_in:
try: try:
return json.load(f_in) return json.load(f_in)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment