jztools.serializer.serializer#

Functions

class_name(x)

Classes

Serializer([extension_types])

Extension of JSON serializer that also supports objects implementing or being supported by a TypeSerializable interface as well lists, tuples, sets and dictionaries (with string keys) of such objects.

Exceptions

ExtensionMissing(in_type)

UnserializableType(in_type)

exception jztools.serializer.serializer.ExtensionMissing(in_type)#

Bases: TypeError

exception jztools.serializer.serializer.UnserializableType(in_type)#

Bases: TypeError

class jztools.serializer.serializer.Serializer(extension_types: Iterable[AbstractTypeSerializer] = ())#

Bases: object

Extension of JSON serializer that also supports objects implementing or being supported by a TypeSerializable interface as well lists, tuples, sets and dictionaries (with string keys) of such objects. Note that, unlike the default json behavior, Serializer preserves types such as tuple and list.

Default extensions include slice objects and numpy.dtype objects.

Parameters:

extension_types – List of types that implement Serializable that the serializer will take into account.

default_extension_types = [<class 'jztools.serializer.extensions.SliceSerializer'>, <class 'jztools.serializer.extensions.DtypeSerializer'>, <class 'jztools.serializer.extensions.NDArraySerializer'>]#

Contains list of external supported types. External modules register their types by appending to this class-level list.

load_safe(filelike, *args, **kwargs)#

Similar to load, but with no errors on empty files. Returns (obj, ‘success’) on success, (None, ‘empty’) if the file is empty, or (None, ‘missing’) if the file does not exist.