{ "info": { "author": "Chris Liveseer", "author_email": "chris@liveseer.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: BSD License", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: Implementation :: CPython" ], "description": "# Starlette Json\n\n## Introduction\nStarlette json responses for various json serializers available in the python community.\n\n### Why:\n- Remove `ujson` dependency from core starlette package\n- Add adaptors for other serializers\n- Customize serializer rendering settings\n\n## Requirements\n- Python 3.6+\n- [Starlette](https://github.com/encode/starlette)\n\n## Installation\n```console\n$ pip install starlette-json\n```\n\n## Optional installs\nInstall at least one of these:\n- [orjson](https://github.com/ijl/orjson) `pip install orjson`\n- [Ultrajson](https://github.com/esnme/ultrajson) `pip install ujson`\n- [Rapidjson](https://github.com/python-rapidjson/python-rapidjson) `pip install python-rapidjson`\n- [SimpleJson](https://github.com/simplejson/simplejson) `pip install simplejson`\n\n## Usage\n### Response examples\n```python\nfrom starlette.applications import Starlette\nfrom starlette.responses import JSONResponse\n\nfrom starlette_json import ORJsonResponse, UJsonResponse, RapidJsonResponse, SimpleJsonResponse\n\napp = Starlette()\ndata = {'Hello': 'World'}\n\n@app.route('/json')\ndef json(request):\n\treturn JSONResponse(data)\n\n@app.route('/orjson')\ndef orjson(request):\n\treturn ORJsonResponse(data)\n\n@app.route('/ujson')\ndef ujson(request):\n\treturn UJsonResponse(data)\n\n@app.route('/rapidjson')\ndef rapidjson(request):\n\treturn RapidJsonResponse(data)\n\n@app.route('/simplejson')\ndef rapidjson(request):\n\treturn SimpleJsonResponse(data)\n```\n\n### Custom response rendering options:\nSee the docs for the specific json serializer for available options\n\n```python\nfrom starlette.applications import Starlette\nfrom starlette_json import ORJsonResponse, UJsonResponse, RapidJsonResponse\nimport orjson\n\napp = Starlette()\ndata = {'Hello': 'World'}\n\n@app.route('/orjson')\ndef orjson(request):\n\treturn ORJsonResponse(\n\t\tdata,\n\t\tdefault=lambda x: str(x),\n\t\toption=orjson.OPT_STRICT_INTEGER | orjson.OPT_NAIVE_UTC\n\t)\n\n@app.route('/ujson')\ndef ujson(request):\n\treturn UJsonResponse(\n\t\tdata,\n\t\tencode_html_chars=True,\n\t\tensure_ascii=False,\n\t\tescape_forward_slashes=False\n\t)\n\n@app.route('/rapidjson')\ndef rapidjson(request):\n\treturn RapidJsonResponse(data, sort_keys=True, indent=4)\n\n@app.route('/simplejson')\ndef rapidjson(request):\n\treturn SimpleJsonResponse(\n\t\tdata,\n\t\tskipkeys=False,\n\t\tensure_ascii=True,\n\t\tcheck_circular=True,\n\t\tallow_nan=True\n\t)\n```\n\n### Json request body parsing:\n```python\nfrom starlette.applications import Starlette\nfrom starlette_json import ORJsonMiddleware, ORJsonResponse\n\napp = Starlette()\n\napp.add_middleware(ORJsonMiddleware)\n\n@app.route('/orjson')\ndef orjson(request):\n\tbody = await request.json() # Parsed with orjson\n\treturn ORJsonResponse({'message':'ok'})\n```\n\n## Contributing\nPRs very welcome.\n[CONTRIBUTING.md](CONTRIBUTING.md)\n\n### Todo\n- Tests?\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/chrisliveseer/starlette-json", "keywords": "starlette json ujson orjson rapidjson", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "starlette-json", "package_url": "https://pypi.org/project/starlette-json/", "platform": "any", "project_url": "https://pypi.org/project/starlette-json/", "project_urls": { "Homepage": "https://github.com/chrisliveseer/starlette-json" }, "release_url": "https://pypi.org/project/starlette-json/20.9.18/", "requires_dist": [ "starlette" ], "requires_python": ">=3.6.0", "summary": "Custom json serializers for the Starlette web framework.", "version": "20.9.18", "yanked": false, "yanked_reason": null }, "last_serial": 8216384, "releases": { "19.10.24": [ { "comment_text": "", "digests": { "md5": "2a1e3deb7775c0910c829af00163dfbe", "sha256": "b5c60ee7cb83d69cc23b7c3fdcab8e7a825a95af32e664f9c54895dfaa430e23" }, "downloads": -1, "filename": "starlette_json-19.10.24-py3-none-any.whl", "has_sig": false, "md5_digest": "2a1e3deb7775c0910c829af00163dfbe", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0", "size": 5787, "upload_time": "2019-10-24T18:21:19", "upload_time_iso_8601": "2019-10-24T18:21:19.012944Z", "url": "https://files.pythonhosted.org/packages/e3/48/60944179900b23a2f4806ce0a419a5ea044815f27c9a994674576d5ee58e/starlette_json-19.10.24-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "3fa3d264e92f5d422dbd44bab915b5c7", "sha256": "a0a7ce0eb3da5a357799759cc7817c1452e0a55ff7ed0ffdb027ab205f8ceef5" }, "downloads": -1, "filename": "starlette_json-19.10.24.tar.gz", "has_sig": false, "md5_digest": "3fa3d264e92f5d422dbd44bab915b5c7", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 3576, "upload_time": "2019-10-24T18:21:21", "upload_time_iso_8601": "2019-10-24T18:21:21.265314Z", "url": "https://files.pythonhosted.org/packages/f6/03/807e527f8ba6d9e47a5c7db77cdb93740c4ca82d5eaedfb0eabe725b9d4d/starlette_json-19.10.24.tar.gz", "yanked": false, "yanked_reason": null } ], "19.10.25": [ { "comment_text": "", "digests": { "md5": "873580622e88f688c0a04ce30bf95303", "sha256": "8ea23118591bfbee12a4f90540d69c7f80df01d23e3736928c1cb7f4d877d146" }, "downloads": -1, "filename": "starlette_json-19.10.25-py3-none-any.whl", "has_sig": false, "md5_digest": "873580622e88f688c0a04ce30bf95303", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0", "size": 6613, "upload_time": "2019-10-25T18:55:32", "upload_time_iso_8601": "2019-10-25T18:55:32.322580Z", "url": "https://files.pythonhosted.org/packages/4b/02/271905715a3caec6394296551ab7167844e014f8931cc9681bb6a819820e/starlette_json-19.10.25-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "36276c102235890a3057b57b09cab3b9", "sha256": "f4a8b2ab0be8db5cf602adab514abd7cf8343f2feb3831b943fdabf47b7d92ce" }, "downloads": -1, "filename": "starlette_json-19.10.25.tar.gz", "has_sig": false, "md5_digest": "36276c102235890a3057b57b09cab3b9", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 3903, "upload_time": "2019-10-25T18:55:34", "upload_time_iso_8601": "2019-10-25T18:55:34.791957Z", "url": "https://files.pythonhosted.org/packages/07/39/6ce8ea90289d6196c3f9ea19726867156552d09bb6d099ff1060112847ad/starlette_json-19.10.25.tar.gz", "yanked": false, "yanked_reason": null } ], "19.11.12": [ { "comment_text": "", "digests": { "md5": "dd16abe905fe1fc8c8a0a383eeab1e92", "sha256": "8b94e6b5e1bde8e34a883e98ef799ac3ed6fa17a2709a02be66957e81c8acef1" }, "downloads": -1, "filename": "starlette_json-19.11.12-py3-none-any.whl", "has_sig": false, "md5_digest": "dd16abe905fe1fc8c8a0a383eeab1e92", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0", "size": 7381, "upload_time": "2019-11-12T21:08:35", "upload_time_iso_8601": "2019-11-12T21:08:35.222637Z", "url": "https://files.pythonhosted.org/packages/58/a4/60445927166ad94c7bb56d58d3cb1230798bbfa66ef61d00ce06500f6977/starlette_json-19.11.12-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "404cbb173f4c4df1314c039dd78563f9", "sha256": "72246a7f067163faf2e94c9e940acf89587c15ca2117144b4c26f76ef37ef605" }, "downloads": -1, "filename": "starlette_json-19.11.12.tar.gz", "has_sig": false, "md5_digest": "404cbb173f4c4df1314c039dd78563f9", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 4221, "upload_time": "2019-11-12T21:08:38", "upload_time_iso_8601": "2019-11-12T21:08:38.091489Z", "url": "https://files.pythonhosted.org/packages/b2/5e/983e968de4a24e8758ecfb122fa1624c69a77188434dcd6810c2af7d7fc3/starlette_json-19.11.12.tar.gz", "yanked": false, "yanked_reason": null } ], "19.11.15": [ { "comment_text": "", "digests": { "md5": "fa5483a7175fc53352bf5315a4096b63", "sha256": "81c4c5027489bd51918da60a032d61171c4dd141934dcba9d94c877d0659fd2f" }, "downloads": -1, "filename": "starlette_json-19.11.15-py3-none-any.whl", "has_sig": false, "md5_digest": "fa5483a7175fc53352bf5315a4096b63", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0", "size": 7398, "upload_time": "2019-11-15T20:09:16", "upload_time_iso_8601": "2019-11-15T20:09:16.756465Z", "url": "https://files.pythonhosted.org/packages/1f/5e/debf80ac022f5a39dcba472c99d67ab9c29bc55f7b4cb61732ff028cb2e1/starlette_json-19.11.15-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "093b16a6c5fabe6932f653eb8e6f7bc5", "sha256": "7f771974c092a87eaa9f11a7109939cba4d8b8be1e64ea75afc08f449fc15b6e" }, "downloads": -1, "filename": "starlette_json-19.11.15.tar.gz", "has_sig": false, "md5_digest": "093b16a6c5fabe6932f653eb8e6f7bc5", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 4275, "upload_time": "2019-11-15T20:09:17", "upload_time_iso_8601": "2019-11-15T20:09:17.857157Z", "url": "https://files.pythonhosted.org/packages/40/d2/a146b2c12f7298e1deab425e5cc13faa42972764a6bef3f178dbea61c5db/starlette_json-19.11.15.tar.gz", "yanked": false, "yanked_reason": null } ], "20.9.18": [ { "comment_text": "", "digests": { "md5": "b23bfd0e0fb3d1034b7796e9d02e5245", "sha256": "abe3f56e7d4a6ef454e5f8913098c8988d6aa0af0f9484e7b86f6ad446f75bb0" }, "downloads": -1, "filename": "starlette_json-20.9.18-py3-none-any.whl", "has_sig": false, "md5_digest": "b23bfd0e0fb3d1034b7796e9d02e5245", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0", "size": 7370, "upload_time": "2020-09-18T11:16:31", "upload_time_iso_8601": "2020-09-18T11:16:31.727667Z", "url": "https://files.pythonhosted.org/packages/6c/bc/e261c6ef83ef19220568678dfd6a5ca7fe969dcdf22601fd73e84f8a95ed/starlette_json-20.9.18-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "5afd71ed7ba254a6faeb8d7a64327a1f", "sha256": "72bff092df261d6ca101660724ca7831c5e57c820e8447ede4ccceb339fab110" }, "downloads": -1, "filename": "starlette_json-20.9.18.tar.gz", "has_sig": false, "md5_digest": "5afd71ed7ba254a6faeb8d7a64327a1f", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 4253, "upload_time": "2020-09-18T11:16:33", "upload_time_iso_8601": "2020-09-18T11:16:33.202957Z", "url": "https://files.pythonhosted.org/packages/fd/2d/25749c8fabb0f3446b5a66a086b2c3e2eb9529bb59127b69db2bdb8500d1/starlette_json-20.9.18.tar.gz", "yanked": false, "yanked_reason": null } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b23bfd0e0fb3d1034b7796e9d02e5245", "sha256": "abe3f56e7d4a6ef454e5f8913098c8988d6aa0af0f9484e7b86f6ad446f75bb0" }, "downloads": -1, "filename": "starlette_json-20.9.18-py3-none-any.whl", "has_sig": false, "md5_digest": "b23bfd0e0fb3d1034b7796e9d02e5245", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0", "size": 7370, "upload_time": "2020-09-18T11:16:31", "upload_time_iso_8601": "2020-09-18T11:16:31.727667Z", "url": "https://files.pythonhosted.org/packages/6c/bc/e261c6ef83ef19220568678dfd6a5ca7fe969dcdf22601fd73e84f8a95ed/starlette_json-20.9.18-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "5afd71ed7ba254a6faeb8d7a64327a1f", "sha256": "72bff092df261d6ca101660724ca7831c5e57c820e8447ede4ccceb339fab110" }, "downloads": -1, "filename": "starlette_json-20.9.18.tar.gz", "has_sig": false, "md5_digest": "5afd71ed7ba254a6faeb8d7a64327a1f", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 4253, "upload_time": "2020-09-18T11:16:33", "upload_time_iso_8601": "2020-09-18T11:16:33.202957Z", "url": "https://files.pythonhosted.org/packages/fd/2d/25749c8fabb0f3446b5a66a086b2c3e2eb9529bb59127b69db2bdb8500d1/starlette_json-20.9.18.tar.gz", "yanked": false, "yanked_reason": null } ], "vulnerabilities": [] }