def deserialize_json(json):
"""
A helper method for deserializing json into Cytoscape.js elements.
:param json: json representation of Cytoscape.js element
:return: Cytoscape.js element object if json is valid, else json
"""
class_name = json.pop('__classname__', None)
if class_name == 'Element': # type(self).__name__:
obj = Element.__new__(Element) # Make instance without calling __init__
for key, value in json.items():
setattr(obj, key, value)
return obj
else:
return json
评论列表
文章目录