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.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.0.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

marshmallow-0.3.0-py2.py3-none-any.whl (19.4 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

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

File hashes

Hashes for marshmallow-0.3.0.tar.gz
Algorithm Hash digest
SHA256 0f607057f69229c48d358fd8e098ddb70c9df3b1243b1f695e0ffcd1277493ca
MD5 b262208e54cc91fc957a7e98552a66dd
BLAKE2b-256 b57c2510fbe91d7a10b6a21c8e203f50ceb156cd05403e04da27606f0c02880c

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for marshmallow-0.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 6758e39b20cd1e044cae04b2617f4193f2e3aceb3a5936974b7ac412f23133aa
MD5 62c97cd1d8a69def1c7955fd4ef13ee2
BLAKE2b-256 dfea4d9eb6bfe8e993ea32c1276a82e140c61f2525a72c69594055b2d8e9aef6

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