Some extra sweets for marshmallow.
Project description
Some extra sweets for marshmallow.
Examples
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 foo.bar.baz == "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 |
dt.date |
fields.Date |
dt.timedelta |
fields.TimeDelta |
All fields will be required for make it optional use typing.Optional[X]
Many
annotation |
marshmallow field |
---|---|
list |
fields.Raw(many=True) |
typing.List[float] |
fields.List(fields.Float()) |
Nested
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
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-jam-1.2.0.tar.gz
.
File metadata
- Download URL: marshmallow-jam-1.2.0.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff3fa72b9f7023e487cfcbeb56f56257add45cd5f7c012b41ad4fb35f06707c0 |
|
MD5 | a090c5b7fa5e8d48bd84ca6a14440876 |
|
BLAKE2b-256 | 6bb4760911a9496b6474e08fba5178a5516dc07222f48b3bf26b1b2335532f9f |
File details
Details for the file marshmallow_jam-1.2.0-py3-none-any.whl
.
File metadata
- Download URL: marshmallow_jam-1.2.0-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf05569cebbb4321ca46a4c8ee9057163248a5ae0fa4bd3bb0641d39dc0d9812 |
|
MD5 | df8e7977d9c9b4ebaa6f70ff28a78046 |
|
BLAKE2b-256 | 6c5e3e13a138c69b46297d58feddb9fae3da61ac6ca3ed67f4030c2a15d59698 |