pyjackson package¶
-
pyjackson.deserialize(obj, as_class: Union[Type[CT_co], pyjackson.generics.Serializer])[source]¶ Convert python dict into given class
Parameters: - obj – dict (or list or any primitive) to deserialize
- as_class – type or serializer
Returns: deserialized instance of as_class (or real_type of serializer)
Raise: DeserializationError
-
pyjackson.dump(fp, obj, as_class: type = None)[source]¶ Serialize obj to JSON as as_class and write it to file-like fp
Parameters: - fp – file-like object to write
- obj – object to serialize
- as_class – type or serializer
Returns: bytes written
-
pyjackson.dumps(obj, as_class: type = None)[source]¶ Serialize obj to JSON string as as_class
Parameters: - obj – object to serialize
- as_class – type or serializer
Returns: JSON string representation
-
pyjackson.load(fp, as_class: type)[source]¶ Deserialize content of file-like fp to as_class instance
Parameters: - fp – file-like object to read
- as_class – type or serializer
Returns: deserialized instance of as_class (or real_type of serializer)
-
pyjackson.loads(payload: str, as_class: type)[source]¶ Deserialize payload to as_class instance
Parameters: - payload – JSON string
- as_class – type or serializer
Returns: deserialized instance of as_class (or real_type of serializer)
-
pyjackson.read(path: str, as_class: Type[T]) → T[source]¶ Deserialize object from file in path as as_class
Parameters: - path – path to file with JSON representation
- as_class – type or serializer
Returns: deserialized instance of as_class (or real_type of serializer)