marshmallow-jsonapi


Namemarshmallow-jsonapi JSON
Version 0.16.0 PyPI version JSON
download
home_pagehttps://github.com/marshmallow-code/marshmallow-jsonapi
SummaryJSON API 1.0 (https://jsonapi.org) formatting with marshmallow
upload_time2017-11-08 22:54:25
maintainer
docs_urlNone
authorSteven Loria
requires_python
licenseMIT
keywords marshmallow-jsonapi marshmallow marshalling serialization jsonapi deserialization validation
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            *******************
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.python.org/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.
            

Raw data

            {
    "maintainer": "", 
    "docs_url": null, 
    "requires_python": "", 
    "maintainer_email": "", 
    "cheesecake_code_kwalitee_id": null, 
    "keywords": "marshmallow-jsonapi marshmallow marshalling serialization jsonapi deserialization validation", 
    "upload_time": "2017-11-08 22:54:25", 
    "author": "Steven Loria", 
    "home_page": "https://github.com/marshmallow-code/marshmallow-jsonapi", 
    "github_user": "marshmallow-code", 
    "download_url": "https://pypi.python.org/packages/8f/84/9c330c97c28bf7833dcb39c26bfcede635d63dfaeae8f86b4846f0bbebe9/marshmallow-jsonapi-0.16.0.tar.gz", 
    "platform": "", 
    "version": "0.16.0", 
    "cheesecake_documentation_id": null, 
    "description": "*******************\nmarshmallow-jsonapi\n*******************\n\n.. image:: https://badge.fury.io/py/marshmallow-jsonapi.svg\n    :target: http://badge.fury.io/py/marshmallow-jsonapi\n    :alt: Latest version\n\n.. image:: https://travis-ci.org/marshmallow-code/marshmallow-jsonapi.svg\n    :target: https://travis-ci.org/marshmallow-code/marshmallow-jsonapi\n    :alt: Travis-CI\n\nHomepage: http://marshmallow-jsonapi.readthedocs.io/\n\nJSON API 1.0 (`https://jsonapi.org <http://jsonapi.org/>`_) formatting with `marshmallow <https://marshmallow.readthedocs.io>`_.\n\nmarshmallow-jsonapi provides a simple way to produce JSON API-compliant data in any Python web framework.\n\n.. code-block:: python\n\n    from marshmallow_jsonapi import Schema, fields\n\n    class PostSchema(Schema):\n        id = fields.Str(dump_only=True)\n        title = fields.Str()\n\n        author = fields.Relationship(\n            '/authors/{author_id}',\n            related_url_kwargs={'author_id': '<author.id>'},\n        )\n\n        comments = fields.Relationship(\n            '/posts/{post_id}/comments',\n            related_url_kwargs={'post_id': '<id>'},\n            # Include resource linkage\n            many=True, include_resource_linkage=True,\n            type_='comments'\n        )\n\n        class Meta:\n            type_ = 'posts'\n            strict = True\n\n    post_schema = PostSchema()\n    post_schema.dump(post).data\n    # {\n    #     \"data\": {\n    #         \"id\": \"1\",\n    #         \"type\": \"posts\"\n    #         \"attributes\": {\n    #             \"title\": \"JSON API paints my bikeshed!\"\n    #         },\n    #         \"relationships\": {\n    #             \"author\": {\n    #                 \"links\": {\n    #                     \"related\": \"/authors/9\"\n    #                 }\n    #             },\n    #             \"comments\": {\n    #                 \"links\": {\n    #                     \"related\": \"/posts/1/comments/\"\n    #                 }\n    #                 \"data\": [\n    #                     {\"id\": 5, \"type\": \"comments\"},\n    #                     {\"id\": 12, \"type\": \"comments\"}\n    #                 ],\n    #             }\n    #         },\n    #     }\n    # }\n\nInstallation\n============\n::\n\n    pip install marshmallow-jsonapi\n\n\nDocumentation\n=============\n\nFull documentation is available at https://marshmallow-jsonapi.readthedocs.io/.\n\nRequirements\n============\n\n- Python >= 2.7 or >= 3.4\n\nProject Links\n=============\n\n- Docs: http://marshmallow-jsonapi.readthedocs.io/\n- Changelog: http://marshmallow-jsonapi.readthedocs.io/en/latest/changelog.html\n- PyPI: https://pypi.python.org/pypi/marshmallow-jsonapi\n- Issues: https://github.com/marshmallow-code/marshmallow-jsonapi/issues\n\nLicense\n=======\n\nMIT licensed. See the bundled `LICENSE <https://github.com/marshmallow-code/marshmallow-jsonapi/blob/master/LICENSE>`_ file for more details.", 
    "tox": true, 
    "lcname": "marshmallow-jsonapi", 
    "bugtrack_url": null, 
    "github": true, 
    "coveralls": false, 
    "name": "marshmallow-jsonapi", 
    "license": "MIT", 
    "travis_ci": true, 
    "github_project": "marshmallow-jsonapi", 
    "summary": "JSON API 1.0 (https://jsonapi.org) formatting with marshmallow", 
    "split_keywords": [
        "marshmallow-jsonapi", 
        "marshmallow", 
        "marshalling", 
        "serialization", 
        "jsonapi", 
        "deserialization", 
        "validation"
    ], 
    "author_email": "sloria1@gmail.com", 
    "urls": [
        {
            "has_sig": false, 
            "upload_time": "2017-11-08T22:54:25", 
            "comment_text": "", 
            "python_version": "source", 
            "url": "https://pypi.python.org/packages/8f/84/9c330c97c28bf7833dcb39c26bfcede635d63dfaeae8f86b4846f0bbebe9/marshmallow-jsonapi-0.16.0.tar.gz", 
            "md5_digest": "6e5261e4b457d89cfeb709bf29961241", 
            "downloads": 0, 
            "filename": "marshmallow-jsonapi-0.16.0.tar.gz", 
            "packagetype": "sdist", 
            "path": "8f/84/9c330c97c28bf7833dcb39c26bfcede635d63dfaeae8f86b4846f0bbebe9/marshmallow-jsonapi-0.16.0.tar.gz", 
            "size": 30390
        }
    ], 
    "_id": null, 
    "cheesecake_installability_id": null
}