json_serializable

Base class for all objects that need to be JSON serializable.

class JSONSerializable[source]

Bases: object

Base class for all objects that need to be JSON serializable.

Implements “to_json” and “from_json” for serialization and deserialization, respectively. Other classes that also need to be JSON serializable have to inherit from this class and reimplement these methods, if necessary.

classmethod from_json(json_dict)[source]

Read this object from a dictionary saved in a JSON file.

Parameters:

json_dict (dict) – A dictionary containing all attributes, properties, etc. as saved in the json file.

Returns:

deserialized_object – The object as read from the JSON file.

Return type:

JSONSerializable

to_json()[source]

Convert this object to a dictionary that can be saved in a JSON file.

Returns:

json_dict – The object as dictionary for export to JSON.

Return type:

dict