ska_oso_pdm.schemas.codec¶
The codec module contains classes used by clients to marshall PDM classes to and from JSON. This saves the clients having to instantiate and manipulate the Marshmallow schema directly.
-
class
MarshmallowCodec
[source]¶ MarshmallowCodec marshalls and unmarshalls PDM classes.
The mapping of PDM classes to Marshmallow schema is defined in this class.
-
dumps
(obj)[source]¶ Return a string JSON representation of a PDM instance.
Parameters: obj – the instance to marshall to JSON Returns: a JSON string
-
load_from_file
(cls, path)[source]¶ Load an instance of a PDM class from disk.
Parameters: - cls – the class to create from the file
- path – the path to the file
Returns: an instance of cls
-
loads
(pdm_class, json_data)[source]¶ Create an instance of a PDM class from a JSON string.
Parameters: - pdm_class – the class to create from the JSON
- json_data – the JSON to unmarshall
Returns: an instance of cls
-