timor.utilities.jsonable ======================== .. py:module:: timor.utilities.jsonable Classes ------- .. autoapisummary:: timor.utilities.jsonable.JSONable_mixin Module Contents --------------- .. py:class:: JSONable_mixin JSONable_mixin is a mixin for any class that can be serialized with a json string. .. py:method:: __getstate__() Return objects which will be pickled and saved. .. py:method:: __setstate__(state) Take object from parameter and use it to retrieve class state. .. py:method:: _deduce_package_dir(filepath, content) :staticmethod: Logic for deducing the package directory if the JSONable object is loaded from a file. :param filepath: The path to the file. :param content: The content of the file parsed into a dictionary. :note: This method can be overridden by subclasses to provide custom package directory resolution; e.g. Task.py. .. py:method:: from_json_data(d, *args, **kwargs) :classmethod: Create from a json description. .. py:method:: from_json_file(filepath, *args, **kwargs) :classmethod: Factory method to load a class instance from a json file. :param filepath: The path to the json file. :param args: Additional arguments to pass to the from_json_data factory method of the specific class. :param kwargs: Additional arguments to pass to the from_json_data factory method of the specific class. .. py:method:: from_json_string(s, *args, **kwargs) :classmethod: Create from a json string. .. py:method:: to_json_data() The json-compatible serialization. .. py:method:: to_json_file(save_at, *args, **kwargs) Writes the instance to a json file. :param save_at: File location or folder to write the class to. .. py:method:: to_json_string() Return the json string representation.