Skip to main content

JSON API 1.0 (https://jsonapi.org) formatting with marshmallow

Project description

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Description: *******************
marshmallow-jsonapi
*******************

.. image:: https://badge.fury.io/py/marshmallow-jsonapi.svg
:target: http://badge.fury.io/py/marshmallow-jsonapi
:alt: Latest version

.. image:: https://travis-ci.org/marshmallow-code/marshmallow-jsonapi.svg
:target: https://travis-ci.org/marshmallow-code/marshmallow-jsonapi
:alt: Travis-CI

Homepage: http://marshmallow-jsonapi.readthedocs.io/

JSON API 1.0 (`https://jsonapi.org <http://jsonapi.org/>`_) formatting with `marshmallow <https://marshmallow.readthedocs.io>`_.

marshmallow-jsonapi provides a simple way to produce JSON API-compliant data in any Python web framework.

.. code-block:: python

from marshmallow_jsonapi import Schema, fields

class PostSchema(Schema):
id = fields.Str(dump_only=True)
title = fields.Str()

author = fields.Relationship(
'/authors/{author_id}',
related_url_kwargs={'author_id': '<author.id>'},
)

comments = fields.Relationship(
'/posts/{post_id}/comments',
related_url_kwargs={'post_id': '<id>'},
# Include resource linkage
many=True, include_resource_linkage=True,
type_='comments'
)

class Meta:
type_ = 'posts'
strict = True

post_schema = PostSchema()
post_schema.dump(post).data
# {
# "data": {
# "id": "1",
# "type": "posts"
# "attributes": {
# "title": "JSON API paints my bikeshed!"
# },
# "relationships": {
# "author": {
# "links": {
# "related": "/authors/9"
# }
# },
# "comments": {
# "links": {
# "related": "/posts/1/comments/"
# }
# "data": [
# {"id": 5, "type": "comments"},
# {"id": 12, "type": "comments"}
# ],
# }
# },
# }
# }

Installation
============
::

pip install marshmallow-jsonapi


Documentation
=============

Full documentation is available at https://marshmallow-jsonapi.readthedocs.io/.

Requirements
============

- Python >= 2.7 or >= 3.4

Project Links
=============

- Docs: http://marshmallow-jsonapi.readthedocs.io/
- Changelog: http://marshmallow-jsonapi.readthedocs.io/en/latest/changelog.html
- PyPI: https://pypi-hypernode.com/pypi/marshmallow-jsonapi
- Issues: https://github.com/marshmallow-code/marshmallow-jsonapi/issues

License
=======

MIT licensed. See the bundled `LICENSE <https://github.com/marshmallow-code/marshmallow-jsonapi/blob/master/LICENSE>`_ file for more details.

Keywords: marshmallow-jsonapi marshmallow marshalling serialization jsonapi deserialization validation
Platform: UNKNOWN
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5

Project details


Download files

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

Source Distribution

marshmallow-jsonapi-0.9.0.tar.gz (26.2 kB view details)

Uploaded Source

Built Distribution

marshmallow_jsonapi-0.9.0-py2.py3-none-any.whl (14.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file marshmallow-jsonapi-0.9.0.tar.gz.

File metadata

File hashes

Hashes for marshmallow-jsonapi-0.9.0.tar.gz
Algorithm Hash digest
SHA256 d933199f3e115a7b75fd1cff02abc9f8a2a8af8825c6c69c6cda860a39ac4d07
MD5 4147c35fb83c9a0c65ccb3067c71fb6e
BLAKE2b-256 e5d5f121758ce6394c2c9cc96b2cc3f2633b7d57aa4e59c816e35544d546c283

See more details on using hashes here.

Provenance

File details

Details for the file marshmallow_jsonapi-0.9.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for marshmallow_jsonapi-0.9.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 6653fb57305ec69900945a4bcd9c397272a2de5332d6e72ad173ffca60227301
MD5 0af9a8f3d2b5bc505e109fa0de03f3bf
BLAKE2b-256 2090a4c7ffe793c9e7a2257e938a0cae62e961130105d31566ac88b034fb24a4

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