Commit 771f3fa0 authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[library] Use error_on_duplicate_key_hook when loading data

parent 1df8de0d
......@@ -43,7 +43,7 @@ Validation for libraries
"""
import os
import simplejson
import simplejson as json
from . import loader
from . import utils
......@@ -164,7 +164,14 @@ class Library(object):
return
with open(json_path, "rb") as f:
self.data = simplejson.loads(f.read().decode("utf-8"))
try:
self.data = json.loads(
f.read().decode("utf-8"),
object_pairs_hook=utils.error_on_duplicate_key_hook,
)
except RuntimeError as error:
self.errors.append("Library declaration file invalid: %s" % error)
return
self.code_path = self.storage.code.path
......@@ -318,7 +325,7 @@ class Library(object):
"""
return simplejson.dumps(self.data, indent=indent, cls=utils.NumpyJSONEncoder)
return json.dumps(self.data, indent=indent, cls=utils.NumpyJSONEncoder)
def __str__(self):
return self.json_dumps()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment