{ "info": { "author": "Imbolc", "author_email": "imbolc@imbolc.name", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: ISC License (ISCL)", "Programming Language :: Python :: 3" ], "description": "asjson\n======\njson.dumps with datetime, date and bson.ObjectId support\n\n >>> from datetime import datetime, date, timedelta, timezone\n >>> from decimal import Decimal\n >>> from bson import ObjectId\n >>> import asjson\n\n >>> data = {\n ... 'time': [\n ... date(2018, 3, 6),\n ... datetime(2018, 3, 6, 9, 38, 0, 1),\n ... datetime(2018, 3, 6, 9, 38, 0, 1).replace(\n ... tzinfo=timezone.utc),\n ... ],\n ... 'decimal': Decimal('3.14'),\n ... 'objectid': ObjectId('a' * 24),\n ... }\n\nWe can make all the values json-appropriate without\ndumping the structure to string.\nIt can be helpful in some cases, e.g. with passing it\ninto database json field.\n\n >>> asjson.encode(data)\n {'time': ['2018-03-06',\n '2018-03-06T09:38:00.000001',\n '2018-03-06T09:38:00.000001+00:00'],\n 'decimal': '3.14',\n 'objectid': 'aaaaaaaaaaaaaaaaaaaaaaaa'}\n\nFor dumping to string we can use `asjson.dumps` which takes\nthe same parameters as standard `json.dumps` does plus `debug`\nwhich just a shortcut for\n`json.dumps(..., indent=4, sort_keys=True, ensure_askii=False)`:\n\n >>> print(asjson.dumps(data, debug=True))\n {\n \"decimal\": \"3.14\",\n \"objectid\": \"aaaaaaaaaaaaaaaaaaaaaaaa\",\n \"time\": [\n \"2018-03-06\",\n \"2018-03-06T09:38:00.000001\",\n \"2018-03-06T09:38:00.000001+00:00\"\n ]\n }", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/imbolc/asjson", "keywords": "", "license": "ISC", "maintainer": "", "maintainer_email": "", "name": "asjson", "package_url": "https://pypi.org/project/asjson/", "platform": "", "project_url": "https://pypi.org/project/asjson/", "project_urls": { "Homepage": "https://github.com/imbolc/asjson" }, "release_url": "https://pypi.org/project/asjson/3.0.0/", "requires_dist": null, "requires_python": "", "summary": "json.dumps with datetime, date and bson.ObjectId support", "version": "3.0.0" }, "last_serial": 3740894, "releases": { "1.2.1": [ { "comment_text": "", "digests": { "md5": "e5e55935aa4213e17f5e886effa59df8", "sha256": "674a3d8188adae0033fa70738ad34e6909ec22b19a71d9e70a0f8e62321ed703" }, "downloads": -1, "filename": "asjson-1.2.1.tar.gz", "has_sig": false, "md5_digest": "e5e55935aa4213e17f5e886effa59df8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2341, "upload_time": "2013-07-30T02:44:33", "url": "https://files.pythonhosted.org/packages/40/13/13744481c134ed1be7be105b4e92bafc5a3194c5dff0890f9f8e7b94eae1/asjson-1.2.1.tar.gz" } ], "2.0.0": [ { "comment_text": "", "digests": { "md5": "1e05e4e79e829df340aeae4b546edb34", "sha256": "099b169659ddbd0054280b3516cb2a4d9c2ec9753327ee6e149d75fba020f315" }, "downloads": -1, "filename": "asjson-2.0.0.tar.gz", "has_sig": false, "md5_digest": "1e05e4e79e829df340aeae4b546edb34", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1701, "upload_time": "2015-11-13T21:33:47", "url": "https://files.pythonhosted.org/packages/39/29/053523c1e99896d3aae84975156efeb2dff374cfe6477430ed443a56cba1/asjson-2.0.0.tar.gz" } ], "3.0.0": [ { "comment_text": "", "digests": { "md5": "c4b9f9ae94e1072aa073f36deb641194", "sha256": "919285397066cace2a430ea83e7bd09e5d2ef2777d4ab9b8922d7c15e921f9af" }, "downloads": -1, "filename": "asjson-3.0.0.tar.gz", "has_sig": false, "md5_digest": "c4b9f9ae94e1072aa073f36deb641194", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2208, "upload_time": "2018-04-06T11:38:50", "url": "https://files.pythonhosted.org/packages/08/84/c3ce2005d6c0f239b511398b45a5f0620aff6b06a180a6984feac37b13d3/asjson-3.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c4b9f9ae94e1072aa073f36deb641194", "sha256": "919285397066cace2a430ea83e7bd09e5d2ef2777d4ab9b8922d7c15e921f9af" }, "downloads": -1, "filename": "asjson-3.0.0.tar.gz", "has_sig": false, "md5_digest": "c4b9f9ae94e1072aa073f36deb641194", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2208, "upload_time": "2018-04-06T11:38:50", "url": "https://files.pythonhosted.org/packages/08/84/c3ce2005d6c0f239b511398b45a5f0620aff6b06a180a6984feac37b13d3/asjson-3.0.0.tar.gz" } ] }