Skip to main content

A lightweight library for converting complex datatypes into native Python datatypes.

Project description

Latest version Travis-CI

Homepage: http://marshmallow.rtfd.org/

marshmallow is an ORM/ODM/framework-agnostic library for converting complex datatypes, such as objects, into native Python datatypes. The serialized objects can then be rendered to standard formats such as JSON for use in a REST API.

from datetime import datetime
from marshmallow import Serializer, fields

# A "model"
class Person(object):
    def __init__(self, name):
        self.name = name
        self.date_born = datetime.now()

# A serializer
class PersonSerializer(Serializer):
    name = fields.String()
    date_born = fields.DateTime()

person = Person("Guido van Rossum")
serialized = PersonSerializer(person)
serialized.data
# {"name": "Guido van Rossum", "date_born": "Sun, 10 Nov 2013 14:24:50 -0000"}

Get It Now

$ pip install -U marshmallow

Documentation

Full documentation is available at http://marshmallow.rtfd.org/ .

Requirements

  • Python >= 2.6 or >= 3.3

License

MIT licensed. See the bundled LICENSE file for more details.

Changelog

0.3.1 (2013-11-16)

  • Fix bug with serializing dictionaries.

  • Fix error raised when serializing empty list.

  • Add only and exclude 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.

0.3.0 (2013-11-14)

  • Declaring Serializers just got easier. The class Meta paradigm allows you to specify fields more concisely. Can specify fields and exclude options.

  • Allow date formats to be changed by passing format parameter to DateTime 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.

0.2.1 (2013-11-12)

  • Allow prefixing field names.

  • Fix storing errors on Nested Serializers.

  • Python 2.6 support.

0.2.0 (2013-11-11)

  • 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 a Serializer.

  • Add relative paramater to fields.Url that allows for relative URLs.

0.1.0 (2013-11-10)

  • First release.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

marshmallow-0.3.1.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

marshmallow-0.3.1-py2.py3-none-any.whl (20.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file marshmallow-0.3.1.tar.gz.

File metadata

  • Download URL: marshmallow-0.3.1.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for marshmallow-0.3.1.tar.gz
Algorithm Hash digest
SHA256 441a2e4a4f259e7720e685d1c97481d93c628b80574b974df7dd82e2a0984132
MD5 e21ba80efc462e9d3bc5faf160b0ff2a
BLAKE2b-256 7c1836c3db50397d2697e60f46a0ae3ecbee8d5c3cdfa79599338f67e63ca14e

See more details on using hashes here.

Provenance

File details

Details for the file marshmallow-0.3.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for marshmallow-0.3.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 bdb7d3cb58b84fe5cb073478d95613f51174050ebfdaadffac1550c70a2ffb81
MD5 028fdaefb56149f4e1a6727c077d68d3
BLAKE2b-256 a07f353deed4e0910174f3008052d5ee1463a1dede7df2ae52e8ccfddfa1647c

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page