Serialization#

Data in Redis#

pydantic-sqs uses Redis Hashes to store data. The `_primary_key_field` of each Model is used as the key of the hash.

Because Redis only supports string values as the fields of a hash, data types have to be serialized.

Simple data types#

Simple python datatypes that can be represented as a string and natively converted by pydantic are converted to strings and stored. Examples are ints, floats, strs, bools, and Nonetypes.

Complex data types#

Complex data types are dumped to json with json.dumps().

Custom serialization is possible using json_default and json_object_hook.

These methods are part of the abstract model and can be overridden in your model to dump custom objects to json and then back to objects. An example is available in examples