diff --git a/beat/core/schema/__init__.py b/beat/core/schema/__init__.py index 0c79fe748aa1366f83491d136a5091faad4bfdcd..ae809022eb9a8b3ee7f337259770e44b9794cbdd 100644 --- a/beat/core/schema/__init__.py +++ b/beat/core/schema/__init__.py @@ -41,7 +41,7 @@ import collections import pkg_resources import six -import simplejson +import simplejson as json import jsonschema @@ -55,7 +55,7 @@ def maybe_load_json(s): with open(s, "rt") as f: return maybe_load_json(f) else: - return simplejson.loads(s, object_pairs_hook=collections.OrderedDict) + return json.loads(s, object_pairs_hook=collections.OrderedDict) # if it is a 'file-like' object if hasattr(s, "read"): @@ -94,7 +94,7 @@ def load_schema(schema_name, version=1): with open(fname, "rb") as f: data = f.read().decode() - schema = simplejson.loads(data) + schema = json.loads(data) basedir = os.path.realpath(os.path.dirname(fname)) resolver = jsonschema.RefResolver("file://" + basedir + "/", schema) @@ -118,7 +118,7 @@ def validate(schema_name, data): try: cleaned_data, error_list = validate('toolchain', '/to/my/file.json') - except simplejson.JSONDecodeError as e: + except json.JSONDecodeError as e: print(e) @@ -133,12 +133,12 @@ def validate(schema_name, data): If ``data`` is a string and represents a valid filesystem path, the relevant file will be opened and read as with - :py:func:`simplejson.load``. Otherwise, it will be considered to be + :py:func:`json.load``. Otherwise, it will be considered to be string containing a valid JSON structure that will be loaded as with - :py:func:`simplejson.loads`. + :py:func:`json.loads`. Note that if the file is opened and read internally using - :py:func:`simplejson.load`, exceptions may be thrown by that subsystem, + :py:func:`json.load`, exceptions may be thrown by that subsystem, concerning the file structure. Consult the manual page for :py:mod:`simplejson` for details. @@ -157,7 +157,7 @@ def validate(schema_name, data): try: data = maybe_load_json(data) - except simplejson.JSONDecodeError as e: + except json.JSONDecodeError as e: return data, ["invalid JSON code: %s" % str(e)] # handles the schema version