Serialization

transmute-core provides a framework and default implementation to allow serializing objects to and from common data representation for an API. This is by chaining two parts:

  1. object serialization to / from basic Python data types.
  2. data types serialization to / from standard data notations (e.g. json or yaml)

out of the box, object serialization is supported for:

  • bool
  • float
  • int
  • str
  • decimal.Decimal
  • datetime.datetime
  • lists, denoted by the form [<type] (deprecated)
  • schematics models.
  • schematics types
    • if a type class is passed, it will initialize the class to an instance.
  • experimental support for attrs classes, specifically using cattrs’s typed notation. This is temporary and will be replaced by attrs’ type parameter.
  • types denoted using the typing module (python 3.5.4+ and 3.6.2+ only)

Customization

TransmuteContext

Both of these components are customizable, either through passing a new TransmuteContext object, or modifying the default instance.

To learn more about customizing these serializers, please see the API reference for TransmuteContext, ObjectSerializer, and ContentTypeSerializer.