JSONSerializerDeserializer#

class gufe.custom_json.JSONSerializerDeserializer(codecs: Iterable[JSONCodec])#

Tools to serialize and deserialize objects as JSON.

This wrapper object is necessary so that we can register new codecs after the original initialization.

encoder#

subclass of JSONEncoder; use as json.dumps(obj, cls=encoder)

decoder#

subclass of JSONDecoder; use as json.loads(string, cls=decoder)

Parameters:

codecs (list of JSONCodecs) – codecs supported

Methods

add_codec

Add a new codec to the supported codecs

deserializer

Callable to loads JSON

serializer

Callable that dumps to JSON

add_codec(codec: JSONCodec)#

Add a new codec to the supported codecs

Parameters:

codec (JSONCodec) – codec to add

deserializer(string: str) Any#

Callable to loads JSON

serializer(obj: Any) str#

Callable that dumps to JSON