Deserialisation
API for the extensible JSON deserialisation registry.
register_deserialiser
registration decorator for functions to inflate objects that were serialised using json.
Functions are added to a dict which is used by the deserialise_object() function. The type string(s) must uniquely identify the appropriate value for the dict 'type' entry, e.g. 'scinexus.composable.NotCompleted'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
str
|
must be unique |
()
|
deserialise_object(data)
deserialises from json
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
PathType | str | dict[str, Any]
|
path to json file, json string or a dict |
required |
Returns:
| Type | Description |
|---|---|
If the dict from json.loads does not contain a "type" key, the object will
|
|
be returned as is. Otherwise, it will be deserialised to the original object.
|
|
Notes
The value of the "type" key is used to identify the specific function for recreating the original instance.
get_class(provenance)
resolve a dotted provenance string to the corresponding class
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provenance
|
str
|
fully qualified class name, e.g. |
required |
str_to_version(v)
parse a version string into a tuple of components
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
str
|
version string, e.g. |
required |