json-api-doc


Namejson-api-doc JSON
Version 0.15.0 PyPI version JSON
download
home_pagehttps://github.com/noplay/json-api-doc
SummaryJSON API to document parser
upload_time2020-11-06 16:01:39
maintainer
docs_urlNone
authorJulien Duponchelle
requires_python
licenseApache Software License 2.0
keywords json api
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            ============
JSON API Doc
============


.. image:: https://img.shields.io/pypi/v/json-api-doc.svg
        :target: https://pypi.python.org/pypi/json-api-doc

.. image:: https://img.shields.io/travis/noplay/json-api-doc.svg
        :target: https://travis-ci.org/noplay/json-api-doc

.. image:: https://readthedocs.org/projects/json-api-doc/badge/?version=latest
        :target: https://json-api-doc.readthedocs.io/en/latest/?badge=latest
        :alt: Documentation Status


.. image:: https://pyup.io/repos/github/noplay/json-api-doc/shield.svg
     :target: https://pyup.io/repos/github/noplay/json-api-doc/
     :alt: Updates



This library provides ability to transform between normalized JSON API
(http://jsonapi.org/) documents and denormalized Python dictionary object for
easier manipulation in code.
Also available as a command line utility and Python 3 module.

Deserialization
~~~~~~~~~~~~~~~

For this JSON API document:

.. code-block:: json

    {
      "data": [{
        "type": "articles",
        "id": "1",
        "attributes": {
          "title": "JSON API paints my bikeshed!",
          "body": "The shortest article. Ever.",
          "created": "2015-05-22T14:56:29.000Z",
          "updated": "2015-05-22T14:56:28.000Z"
        },
        "relationships": {
          "author": {
            "data": {"id": "42", "type": "people"}
          }
        }
      }],
      "included": [
        {
          "type": "people",
          "id": "42",
          "attributes": {
            "name": "John",
            "age": 80,
            "gender": "male"
          }
        }
      ]
    }

The simplified version will be:

.. code-block:: json

    [
        {
            "type": "articles",
            "id": "1",
            "title": "JSON API paints my bikeshed!",
            "body": "The shortest article. Ever.",
            "created": "2015-05-22T14:56:29.000Z",
            "updated": "2015-05-22T14:56:28.000Z",
            "author": {
                "type": "people",
                "id": "42",
                "name": "John",
                "age": 80,
                "gender": "male"
            }
        }
    ]

Serialization
~~~~~~~~~~~~~

To turn an dict into JSON API specification document the root of your object
must contain a `$type` key with a value corresponding to the name of
the object's resource type. Any sub-dict or sub-array of dicts that also
contain a `$type` key will be considered an included documents and serialized
accordingly.

.. code-block:: json

    [
        {
            "$type": "articles",
            "id": "1",
            "title": "JSON API paints my bikeshed!",
            "body": "The shortest article. Ever.",
            "created": "2015-05-22T14:56:29.000Z",
            "updated": "2015-05-22T14:56:28.000Z",
            "author": {
                "$type": "people",
                "id": "42",
                "name": "John",
                "age": 80,
                "gender": "male"
            }
        }
    ]

.. code-block:: json

    {
      "data": [{
        "type": "articles",
        "id": "1",
        "attributes": {
          "title": "JSON API paints my bikeshed!",
          "body": "The shortest article. Ever.",
          "created": "2015-05-22T14:56:29.000Z",
          "updated": "2015-05-22T14:56:28.000Z"
        },
        "relationships": {
          "author": {
            "data": {"id": "42", "type": "people"}
          }
        }
      }],
      "included": [
        {
          "type": "people",
          "id": "42",
          "attributes": {
            "name": "John",
            "age": 80,
            "gender": "male"
          }
        }
      ]
    }

Usage as python module
----------------------

.. code-block:: python

        import json_api_doc

        document =  {
            'data': {
                'type': 'article',
                'id': '1',
                'attributes': {
                    'name': 'Article 1'
                }
            }
        }
        json_api_doc.deserialize(document)

.. code-block:: python

        import json_api_doc

        document =  {
          '$type': 'article',
          'id': '1',
          'name': 'Article 1'
        }
        json_api_doc.serialize(document)

Usage as cli
------------

.. code-block:: bash

    $ jsonapidoc document.json


Contributors
-------------
* Julien Duponchelle (https://github.com/noplay)
* Antonio Martinović (https://github.com/TopHatCroat)
* Jeff Zellman (https://github.com/jzellman)
* Brenda Deely (https://github.com/brendadeely)
* Taylor Hobbs (https://github.com/TayHobbs)

Licence
--------
Free software: Apache Software License 2.0

Documentation
--------------
Full Documentation is available: https://json-api-doc.readthedocs.io.




            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/noplay/json-api-doc",
    "name": "json-api-doc",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "json api",
    "author": "Julien Duponchelle",
    "author_email": "julien@duponchelle.info",
    "download_url": "https://files.pythonhosted.org/packages/82/5f/f2fea5059a8e60e38712eafbfda3fd254ca8f2c44c3b5b3dd94c398ae672/json-api-doc-0.15.0.tar.gz",
    "platform": "",
    "description": "============\nJSON API Doc\n============\n\n\n.. image:: https://img.shields.io/pypi/v/json-api-doc.svg\n        :target: https://pypi.python.org/pypi/json-api-doc\n\n.. image:: https://img.shields.io/travis/noplay/json-api-doc.svg\n        :target: https://travis-ci.org/noplay/json-api-doc\n\n.. image:: https://readthedocs.org/projects/json-api-doc/badge/?version=latest\n        :target: https://json-api-doc.readthedocs.io/en/latest/?badge=latest\n        :alt: Documentation Status\n\n\n.. image:: https://pyup.io/repos/github/noplay/json-api-doc/shield.svg\n     :target: https://pyup.io/repos/github/noplay/json-api-doc/\n     :alt: Updates\n\n\n\nThis library provides ability to transform between normalized JSON API\n(http://jsonapi.org/) documents and denormalized Python dictionary object for\neasier manipulation in code.\nAlso available as a command line utility and Python 3 module.\n\nDeserialization\n~~~~~~~~~~~~~~~\n\nFor this JSON API document:\n\n.. code-block:: json\n\n    {\n      \"data\": [{\n        \"type\": \"articles\",\n        \"id\": \"1\",\n        \"attributes\": {\n          \"title\": \"JSON API paints my bikeshed!\",\n          \"body\": \"The shortest article. Ever.\",\n          \"created\": \"2015-05-22T14:56:29.000Z\",\n          \"updated\": \"2015-05-22T14:56:28.000Z\"\n        },\n        \"relationships\": {\n          \"author\": {\n            \"data\": {\"id\": \"42\", \"type\": \"people\"}\n          }\n        }\n      }],\n      \"included\": [\n        {\n          \"type\": \"people\",\n          \"id\": \"42\",\n          \"attributes\": {\n            \"name\": \"John\",\n            \"age\": 80,\n            \"gender\": \"male\"\n          }\n        }\n      ]\n    }\n\nThe simplified version will be:\n\n.. code-block:: json\n\n    [\n        {\n            \"type\": \"articles\",\n            \"id\": \"1\",\n            \"title\": \"JSON API paints my bikeshed!\",\n            \"body\": \"The shortest article. Ever.\",\n            \"created\": \"2015-05-22T14:56:29.000Z\",\n            \"updated\": \"2015-05-22T14:56:28.000Z\",\n            \"author\": {\n                \"type\": \"people\",\n                \"id\": \"42\",\n                \"name\": \"John\",\n                \"age\": 80,\n                \"gender\": \"male\"\n            }\n        }\n    ]\n\nSerialization\n~~~~~~~~~~~~~\n\nTo turn an dict into JSON API specification document the root of your object\nmust contain a `$type` key with a value corresponding to the name of\nthe object's resource type. Any sub-dict or sub-array of dicts that also\ncontain a `$type` key will be considered an included documents and serialized\naccordingly.\n\n.. code-block:: json\n\n    [\n        {\n            \"$type\": \"articles\",\n            \"id\": \"1\",\n            \"title\": \"JSON API paints my bikeshed!\",\n            \"body\": \"The shortest article. Ever.\",\n            \"created\": \"2015-05-22T14:56:29.000Z\",\n            \"updated\": \"2015-05-22T14:56:28.000Z\",\n            \"author\": {\n                \"$type\": \"people\",\n                \"id\": \"42\",\n                \"name\": \"John\",\n                \"age\": 80,\n                \"gender\": \"male\"\n            }\n        }\n    ]\n\n.. code-block:: json\n\n    {\n      \"data\": [{\n        \"type\": \"articles\",\n        \"id\": \"1\",\n        \"attributes\": {\n          \"title\": \"JSON API paints my bikeshed!\",\n          \"body\": \"The shortest article. Ever.\",\n          \"created\": \"2015-05-22T14:56:29.000Z\",\n          \"updated\": \"2015-05-22T14:56:28.000Z\"\n        },\n        \"relationships\": {\n          \"author\": {\n            \"data\": {\"id\": \"42\", \"type\": \"people\"}\n          }\n        }\n      }],\n      \"included\": [\n        {\n          \"type\": \"people\",\n          \"id\": \"42\",\n          \"attributes\": {\n            \"name\": \"John\",\n            \"age\": 80,\n            \"gender\": \"male\"\n          }\n        }\n      ]\n    }\n\nUsage as python module\n----------------------\n\n.. code-block:: python\n\n        import json_api_doc\n\n        document =  {\n            'data': {\n                'type': 'article',\n                'id': '1',\n                'attributes': {\n                    'name': 'Article 1'\n                }\n            }\n        }\n        json_api_doc.deserialize(document)\n\n.. code-block:: python\n\n        import json_api_doc\n\n        document =  {\n          '$type': 'article',\n          'id': '1',\n          'name': 'Article 1'\n        }\n        json_api_doc.serialize(document)\n\nUsage as cli\n------------\n\n.. code-block:: bash\n\n    $ jsonapidoc document.json\n\n\nContributors\n-------------\n* Julien Duponchelle (https://github.com/noplay)\n* Antonio Martinovi\u0107 (https://github.com/TopHatCroat)\n* Jeff Zellman (https://github.com/jzellman)\n* Brenda Deely (https://github.com/brendadeely)\n* Taylor Hobbs (https://github.com/TayHobbs)\n\nLicence\n--------\nFree software: Apache Software License 2.0\n\nDocumentation\n--------------\nFull Documentation is available: https://json-api-doc.readthedocs.io.\n\n\n\n",
    "bugtrack_url": null,
    "license": "Apache Software License 2.0",
    "summary": "JSON API to document parser",
    "version": "0.15.0",
    "project_urls": {
        "Homepage": "https://github.com/noplay/json-api-doc"
    },
    "split_keywords": [
        "json",
        "api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4b3033f9ccb7e265ff98e17e1662d2871322ea7adbc73d9c8c69ef4d9d5605a7",
                "md5": "b44b7e81ea14b8079b3b012d9a368fd1",
                "sha256": "4a9abc840c8706b17057be8e99958821a133040e891bdb5beac0abe045ab6b1d"
            },
            "downloads": -1,
            "filename": "json_api_doc-0.15.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b44b7e81ea14b8079b3b012d9a368fd1",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 6143,
            "upload_time": "2020-11-06T16:01:36",
            "upload_time_iso_8601": "2020-11-06T16:01:36.706859Z",
            "url": "https://files.pythonhosted.org/packages/4b/30/33f9ccb7e265ff98e17e1662d2871322ea7adbc73d9c8c69ef4d9d5605a7/json_api_doc-0.15.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "825ff2fea5059a8e60e38712eafbfda3fd254ca8f2c44c3b5b3dd94c398ae672",
                "md5": "f4637f1fb1de0ba31e8f4594ab59a157",
                "sha256": "1cbbf34d04b7768bf0de187363333a1c96294588e778f722a98ef60765458a9c"
            },
            "downloads": -1,
            "filename": "json-api-doc-0.15.0.tar.gz",
            "has_sig": false,
            "md5_digest": "f4637f1fb1de0ba31e8f4594ab59a157",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 4933,
            "upload_time": "2020-11-06T16:01:39",
            "upload_time_iso_8601": "2020-11-06T16:01:39.373934Z",
            "url": "https://files.pythonhosted.org/packages/82/5f/f2fea5059a8e60e38712eafbfda3fd254ca8f2c44c3b5b3dd94c398ae672/json-api-doc-0.15.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-11-06 16:01:39",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "noplay",
    "github_project": "json-api-doc",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "tox": true,
    "lcname": "json-api-doc"
}
        
Elapsed time: 0.10572s