- Rename
Serializer
toSchema
. - Support for deserialization.
- Improved
Serializer
interface. Use theSchema.dump
andSchema.load
methods for serializing and deserializing, respectively. - Backwards-incompatible: Remove
Schema.json
andSchema.to_json
. UseSchema.dumps
instead. - Reworked fields interface.
- Backwards-incompatible:
Field
classes implement_format
,_serialize
and_deserialize
methods.serialize
anddeserialize
comprise the public API for aField
.Field.format
andField.output
have been removed. - Backwards-incompatible: Remove
validated
decorator. Validation occurs withinField
methods. - Add
exceptions.ForcedError
which allows errors to be raised during serialization (instead of storing errors in theerrors
dict). - Backwards-incompatible:
Function
field raises aValueError
if an uncallable object is passed to its constructor. - Backwards-incompatible:
DateTime
field serializes to ISO8601 format by default (instead of RFC822). - Backwards-incompatible: Remove Serializer.factory method.
- Backwards-incompatible: Allow nesting a serializer within itself recursively. Use
exclude
oronly
to prevent infinite recursion. Nested
fields inherit context from their parent.- Fix ordering of field output.
- Fix behavior of the
required
parameter onNested
fields. - Fix serializing keyed tuple types (e.g.
namedtuple
) withclass Meta
options. - Fix default value for
Fixed
field. - Fix serialization of binary strings.
Schemas
can inherit fields from non-Schema
base classes (e.g. mixins). Also, fields are inherited according to the MRO (rather than recursing over base classes). Thanks Josh Carp.
- Add
Serializer.error_handler
decorator that registers a custom error handler. - Add
Serializer.data_handler
decorator that registers data post-processing callbacks. - Backwards-incompatible:
process_data
method is deprecated. Use thedata_handler
decorator instead. - Fix bug that raised error when passing
extra
data together withmany=True
. Thanks Joe Alcorn for reporting. - If
required=True
validation is violated for a givenField
, it will raise an error message that is different from the message specified by theerror
argument. Thanks Anders Steinlein. - More generic error message raised when required field is missing.
validated
decorator should only wrap aField
class'soutput
method.
- Fix bug in serializing keyed tuple types, e.g.
namedtuple
andKeyedTuple
. - Nested field can load a serializer by its class name as a string. This makes it easier to implement 2-way nesting.
- Make Serializer.data override-able.
- Add
Serializer.factory
for creating a factory function that returns a Serializer instance. MarshallingError
stores its underlying exception as an instance variable. This is useful for inspecting errors.fields.Select
is aliased tofields.Enum
.- Add
fields.__all__
andmarshmallow.__all__
so that the modules can be more easily extended. - Expose
Serializer.OPTIONS_CLASS
as a class variable so that options defaults can be overridden. - Add
Serializer.process_data
hook that allows subclasses to manipulate the final output data.
- Add
json_module
class Meta option. - Add
required
option to fields . Thanks @DeaconDesperado. - Tested on Python 3.4 and PyPy.
- Fix
Integer
field default. It is now0
instead of0.0
. Thanks @kalasjocke. - Add
context
param toSerializer
. Allows accessing arbitrary objects inFunction
andMethod
fields. Function
andMethod
fields raiseMarshallingError
if their argument is uncallable.
- Enable custom field validation via the
validate
parameter. - Add
utils.from_rfc
for parsing RFC datestring to Python datetime object.
- Avoid unnecessary attribute access in
utils.to_marshallable_type
for improved performance. - Fix RFC822 formatting for localized datetimes.
- Can customize validation error messages by passing the
error
parameter to a field. - Backwards-incompatible: Rename
fields.NumberField
->fields.Number
. - Add
fields.Select
. Thanks @ecarreras. - Support nesting a Serializer within itself by passing
"self"
intofields.Nested
(only up to depth=1). - Backwards-incompatible: No implicit serializing of collections. Must set
many=True
if serializing to a list. This ensures that marshmallow handles singular objects correctly, even if they are iterable. - If Nested field
only
parameter is a field name, only return a single value for the nested object (instead of a dict) or a flat list of values. - Improved performance and stability.
- An object's
__marshallable__
method, if defined, takes precedence over__getitem__
. - Generator expressions can be passed to a serializer.
- Better support for serializing list-like collections (e.g. ORM querysets).
- Other minor bugfixes.
- Add
additional
class Meta option. - Add
dateformat
class Meta option. - Support for serializing UUID, date, time, and timedelta objects.
- Remove
Serializer.to_data
method. Just useSerialize.data
property. - String field defaults to empty string instead of
None
. - Backwards-incompatible:
isoformat
andrfcformat
functions moved to utils.py. - Backwards-incompatible: Validation functions moved to validate.py.
- Backwards-incompatible: Remove types.py.
- Reorder parameters to
DateTime
field (first parameter is dateformat). - Ensure that
to_json
returns bytestrings. - Fix bug with including an object property in
fields
Meta option. - Fix bug with passing
None
to a serializer.
- Fix bug with serializing dictionaries.
- Fix error raised when serializing empty list.
- Add
only
andexclude
parameters to Serializer constructor. - Add
strict
parameter and option: causes Serializer to raise an error if invalid data are passed in, rather than storing errors. - Updated Flask + SQLA example in docs.
- Declaring Serializers just got easier. The class Meta paradigm allows you to specify fields more concisely. Can specify
fields
andexclude
options. - Allow date formats to be changed by passing
format
parameter toDateTime
field constructor. Can either be"rfc"
(default),"iso"
, or a date format string. - More useful error message when declaring fields as classes (instead of an instance, which is the correct usage).
- Rename MarshallingException -> MarshallingError.
- Rename marshmallow.core -> marshmallow.serializer.
- Allow prefixing field names.
- Fix storing errors on Nested Serializers.
- Python 2.6 support.
- Field-level validation.
- Add
fields.Method
. - Add
fields.Function
. - Allow binding of extra data to a serialized object by passing the
extra
param when initializing aSerializer
. - Add
relative
paramater tofields.Url
that allows for relative URLs.
- First release.