Skip to main content

Some extra sweets for marshmallow.

Project description

Some extra sweets for marshmallow.

version pipeline status coverage report python_version


Use annotations for schema description.

from jam import Schema

class Bar(Schema):
    baz: str

class Foo(Schema):
    bar: Bar

foo: Foo = Foo().load({"bar": {"baz": "quux"}})

assert == "quux"

When annotations not enough

class Foo(Schema):
    bar: str = fields.Email()

Mapping rules

Basic Types

annotation marshmallow field
str fields.String
float fields.Float
bool fields.Boolean
int fields.Integer
uuid.UUID fields.UUID
decimal.Decimal fields.Decimal
dt.datetime fields.DateTime
dt.time fields.Time fields.Date
dt.timedelta fields.TimeDelta

All fields will be required for make it optional use typing.Optional[X]


annotation marshmallow field
list fields.Raw(many=True)
typing.List[float] fields.List(fields.Float())


annotation marshmallow field
NestedSchema fields.Nested(NestedSchema, required=True)
typing.Optional[NestedSchema] fields.Nested(NestedSchema, required=True)
typing.List[NestedSchema] fields.Nested(NestedSchema, required=True, many=True)

Project details

Download files

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

Files for marshmallow-jam, version 1.2.0
Filename, size File type Python version Upload date Hashes
Filename, size marshmallow_jam-1.2.0-py3-none-any.whl (5.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size marshmallow-jam-1.2.0.tar.gz (5.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page