A lightweight library for converting complex datatypes into native Python datatypes.
Project description
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.2.1 (2013-11-12)
Allow prefixing field names.
Fix storing of 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
Built Distribution
File details
Details for the file marshmallow-0.2.1.tar.gz
.
File metadata
- Download URL: marshmallow-0.2.1.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 910cdb45710849814be966be7cee4f6ba2cb4f58fc8392fa8aff4c6a1a4ad42b |
|
MD5 | 3bea44ef745c5245d983a21bad05a0b5 |
|
BLAKE2b-256 | 4fab88c6e90d12c7400d206f249085c4a7176c58fb3fc99897f442f52945804e |
Provenance
File details
Details for the file marshmallow-0.2.1-py2.py3-none-any.whl
.
File metadata
- Download URL: marshmallow-0.2.1-py2.py3-none-any.whl
- Upload date:
- Size: 16.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 366c71f1d008ed4e865e2b2c5a2f2a5750627e621263628a55cbfa2e6d73961c |
|
MD5 | 604151acd42e17694c10008fabc29ae1 |
|
BLAKE2b-256 | 6daa92d71a193c5e732ff0b492dbbf08cce9f66084486f24a08fa8cfd57381ec |