{ "info": { "author": "Zeth Green", "author_email": "theology@gmail.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Operating System :: MacOS :: MacOS X", "Operating System :: Microsoft :: Windows", "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 3.7", "Topic :: Internet :: WWW/HTTP", "Topic :: Software Development :: Libraries", "Topic :: Utilities" ], "description": "jsondt\n======\n\nJSON with datetime support.\n\nThis module is a light shim around the existing standard library JSON moduile.\n\nIt encodes and decodes Python datetime objects as human-readable ISO8601 dates.\n\n .. image:: https://raw.githubusercontent.com/zeth/jsondt/master/iso8601.jpg\n\nIt is a drop-in replacement for standard library JSON, so you can just do:\n\n>>> import jsondt as json\n\nThen carry on with the standard library JSON documentation.\n\nCurrently, this module supports only Python 3.7 and above.\n\nBackporting to older versions is possible if there is demand for it.\n\nSimple example\n--------------\n\nHere we go:\n\n>>> import jsondt as json\n>>> from datetime import datetime\n>>> myobject = {'ctime': datetime.now()}\n>>> encoded = json.dumps(myobject)\n>>> print(encoded)\n'{\"ctime\": \"2019-08-19T18:18:25.609815\"}'\n>>> decoded = json.loads(encoded)\n>>> print(decoded)\n{'ctime': datetime.datetime(2019, 8, 19, 18, 18, 25, 609815)}\n>>> myobject == decoded\nTrue\n\nJavaScript compatible\n---------------------\n\nOne of the main use cases is to interoperate with JSON produced by\nJavaScript in the browser.\n\nSpin up your Javascript console:\n\n>>> const record = {'ctime': new Date()}\n>>> const encoded = JSON.stringify(record);\n>>> console.log(encoded)\n{\"ctime\":\"2019-08-19T17:25:03.547Z\"}\n\nNow get that JSON string to Python through your API call or post request\n(here's one that we made earlier):\n\n>>> encoded = '{\"ctime\":\"2019-08-19T17:25:03.547Z\"}'\n>>> import jsondt as json\n>>> json.loads(encoded)\n{'ctime': datetime.datetime(2019, 8, 19, 17, 25, 3, 547000,\ntzinfo=datetime.timezone.utc)}\n\nSay Hello\n---------\n\nI am interested in more common use cases for ISO 8601 dates.\n\nIf you have an ISO 8601 date in JSON produced by a well known application\nor library (in any language) and jsondt does not recognise it, please make\nan issue on GitHub and I will see if I can add support.\n\nControl Mode\n------------\n\nYou probably don't need to care about this bit.\n\nThere is a second mode that is semi-automatic instead of fully-automatic.\n\nImagine we have this strange object:\n\n>>> strange = {'a_date': datetime.datetime(2019, 8, 19, 21, 32, 59, 169730),\n... 'b_date': '2018-05-01T07:03:44.560600'}\n\nIf we dump it and load it back, it will load both dates as datetime objects.\n\n>>> import jsondt as json\n>>> encoded = json.dumps(strange)\n>>> decoded = json.loads(encoded)\n>>> decoded == strange\nFalse\n\nIf however, you prefer the original object back, you can use control mode.\n\n>>> import jsondt as json\n>>> encoded = json.dumps(strange, control=True)\n>>> decoded = json.loads(encoded, control=True)\n>>> decoded == strange\nTrue\n\nThe way it works, is that with control=True, it puts a control code\n(backslash D) at the start of the encoded date. Like so:\n\n>>> print(encoded)\n{\"a_date\": \"\\\\D2019-08-19T21:32:59.169730\",\n \"b_date\": \"2018-05-01T07:03:44.560600\"}\n\nThanks for reading\n------------------\n\nIf you want more examples, read the supplied tests.\n\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/zeth/jsondt", "keywords": "", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "jsondt", "package_url": "https://pypi.org/project/jsondt/", "platform": "", "project_url": "https://pypi.org/project/jsondt/", "project_urls": { "Homepage": "https://github.com/zeth/jsondt" }, "release_url": "https://pypi.org/project/jsondt/1.0.0/", "requires_dist": null, "requires_python": "", "summary": "JSON module with added datetime support.", "version": "1.0.0" }, "last_serial": 5703259, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "774e9d29fd69915ad8e20bb90d25ffb6", "sha256": "4712727467b8d3b292f6e129de013169574e650fe949c5d62c77a5afd9659a20" }, "downloads": -1, "filename": "jsondt-1.0.0-py3.7.egg", "has_sig": false, "md5_digest": "774e9d29fd69915ad8e20bb90d25ffb6", "packagetype": "bdist_egg", "python_version": "3.7", "requires_python": null, "size": 5470, "upload_time": "2019-08-20T13:06:34", "url": "https://files.pythonhosted.org/packages/43/c7/d954b90b58e9f78b1544e388fab407f53621711befd1c3831cd1a120f316/jsondt-1.0.0-py3.7.egg" }, { "comment_text": "", "digests": { "md5": "55323929e731ac17a3a80b9943872420", "sha256": "71ac895897c4d2da9471c1c900de31063b4034181f98e19c523e11b9eaa4d932" }, "downloads": -1, "filename": "jsondt-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "55323929e731ac17a3a80b9943872420", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9709, "upload_time": "2019-08-20T13:06:32", "url": "https://files.pythonhosted.org/packages/39/11/b03dfd8f813a3e07d397fd9fcd615d667002eeac28a22a50f36a57ccf5ae/jsondt-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a549f3e89a03fc3fa6c4682f89132878", "sha256": "866b1fff9f7b2cfd89979790c0b2cc92d9be74861b2d9738430186bce9ad96cc" }, "downloads": -1, "filename": "jsondt-1.0.0.tar.gz", "has_sig": false, "md5_digest": "a549f3e89a03fc3fa6c4682f89132878", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10825, "upload_time": "2019-08-20T13:06:35", "url": "https://files.pythonhosted.org/packages/11/3c/027ee3781623962b7cfdc8f6da814312b5443897ae49b9ff047f708e2b8a/jsondt-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "774e9d29fd69915ad8e20bb90d25ffb6", "sha256": "4712727467b8d3b292f6e129de013169574e650fe949c5d62c77a5afd9659a20" }, "downloads": -1, "filename": "jsondt-1.0.0-py3.7.egg", "has_sig": false, "md5_digest": "774e9d29fd69915ad8e20bb90d25ffb6", "packagetype": "bdist_egg", "python_version": "3.7", "requires_python": null, "size": 5470, "upload_time": "2019-08-20T13:06:34", "url": "https://files.pythonhosted.org/packages/43/c7/d954b90b58e9f78b1544e388fab407f53621711befd1c3831cd1a120f316/jsondt-1.0.0-py3.7.egg" }, { "comment_text": "", "digests": { "md5": "55323929e731ac17a3a80b9943872420", "sha256": "71ac895897c4d2da9471c1c900de31063b4034181f98e19c523e11b9eaa4d932" }, "downloads": -1, "filename": "jsondt-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "55323929e731ac17a3a80b9943872420", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9709, "upload_time": "2019-08-20T13:06:32", "url": "https://files.pythonhosted.org/packages/39/11/b03dfd8f813a3e07d397fd9fcd615d667002eeac28a22a50f36a57ccf5ae/jsondt-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a549f3e89a03fc3fa6c4682f89132878", "sha256": "866b1fff9f7b2cfd89979790c0b2cc92d9be74861b2d9738430186bce9ad96cc" }, "downloads": -1, "filename": "jsondt-1.0.0.tar.gz", "has_sig": false, "md5_digest": "a549f3e89a03fc3fa6c4682f89132878", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10825, "upload_time": "2019-08-20T13:06:35", "url": "https://files.pythonhosted.org/packages/11/3c/027ee3781623962b7cfdc8f6da814312b5443897ae49b9ff047f708e2b8a/jsondt-1.0.0.tar.gz" } ] }