myjson
¶
Module Contents¶
-
MODULE_TAG
= __module__¶
-
CLASS_TAG
= __class__¶
-
EXCLUDED_TAGS
¶
-
class
SaveableObject
[source]¶ Abstract class for dynamically type-hinted objects. This class is to solve the special case where the exact type of an attribute is not known before runtime, yet has to be saved.
-
json_to_obj
(json_dict)[source]¶ Convenience class to create object from dictionary. Only works if CLASS_TAG is valid
Parameters: json_dict – dictionary loaded from a json file.
Raises: - TypeError – if class can not be found
- KeyError – if CLASS_TAG not present in dictionary
-
json_to_obj_safe
(json_dict, cls)[source]¶ Safe class to create object from dictionary.
Parameters: - json_dict – dictionary loaded from a json file
- cls – class object to instantiate with dictionary