{ "info": { "author": "Denis Sazonov", "author_email": "den@saz.lt", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "jsonextra\n=====\n[![Build Status](https://travis-ci.org/den4uk/jsonextra.svg?branch=master)](https://travis-ci.org/den4uk/jsonextra)\n[![Codecov](https://codecov.io/gh/den4uk/jsonextra/branch/master/graph/badge.svg)](https://codecov.io/gh/den4uk/jsonextra)\n[![PyPI Version](http://img.shields.io/pypi/v/jsonextra.svg)](https://pypi.python.org/pypi/jsonextra)\n[![License](https://img.shields.io/github/license/den4uk/jsonextra.svg)](https://pypi.python.org/pypi/jsonextra)\n\n_same as `json` library, but with extra support for `bytes`, `uuid` and `datetime` data classes_\n\n## Installation\n\n```\n$ pip install jsonextra\n```\n\n\n## Usage\n\nUse just like `json` as normal once imported, but with addition of extra data classes.\n\n```python\nimport uuid, datetime # for creation of `my_data` object\nimport jsonextra\n\nmy_data = {'id': uuid.uuid4(), 'created': datetime.date.today()}\n# my_data --> {'id': uuid.UUID('5f7660c5-88ea-46b6-93e2-860d5b7a0271'), 'created': datetime.date(2019, 6, 16)}\n\n# Serializes the key values to stringified versions\nmy_json = jsonextra.dumps(my_data)\n# my_json --> '{\"id\": \"5f7660c5-88ea-46b6-93e2-860d5b7a0271\", \"created\": \"2019-06-16\"}'\n\n# Deserializes the object and confirms the output matches `my_data`\nassert jsonextra.loads(my_json) == my_data # True\n```\n\n\n##### `.dump(obj, fp, **kwargs)` & `.dumps(obj, **kwargs)`\nWill serialize extra data classes into their string (`__str__`) or special representations (_eg: `.isoformat`, etc._).\n\n\n##### `.load(fp, **kwargs)` & `.loads(s, **kwargs)`\nWill deserialize any stings, which match patterns of extra supported data classes.\nFor example, if something looks like a _uuid_ - it will be converted to `uuid.UUID`.\nIf this behaviour is undesired, please use the built-in `json.loads` method instead of `jsonextra.loads`.\n\n\n## Supported extra data classes\n\n| Python Data Class | Python Object (deserialized) | JSON Object (serialized) |\n|-------------------|------------------------------|--------------------------|\n| `datetime.date` | `datetime.date(2019, 1, 1)` | `\"2019-01-01\"` |\n| `datetime.time` | `datetime.time(23, 59, 11)` | `\"23:59:11\"` |\n| `datetime.datetime` | `datetime.datetime(2019, 1, 1, 23, 59, 11)` | `\"2019-01-01T23:59:11\"` |\n| `uuid.UUID` | `uuid.UUID('5f7660c5-88ea-46b6-93e2-860d5b7a0271')` | `\"5f7660c5-88ea-46b6-93e2-860d5b7a0271\"` |\n| `bytes` | `b'\\xd6aO\\x1d\\xd71Y\\x05'` | `\"base64:1mFPHdcxWQU=\"` |\n\nMore examples of serialized/deserialized values can be found in tests ;p\n\n\n## Why?\n\n_Why would you want to use this library?_\n\n- If you work with a model-less data structures, and its data types expend beyond the JSON standard supports.\n- If your model schemas are too dynamic to be able to use model-based serializers, and requires to store more data types.\n- If your data structure does not fit with the JSON standard, and it needs expanding to support one or more data types.\n\n\n## How it works\n\nAn extra supported python object is dumped to a _string_ value.\nWhen loading a serialized json object, any values matching the string supported data class, will be converted to their expected data class instances.\n> _If it looks like a duck, swims like a duck, and quacks like a duck, then it probably is a duck_.\n\n\n## Contributions\n\nContibutions are welcome, please submit your pull requests into `dev` branch for a review.\n\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/den4uk/jsonextra", "keywords": "json,uuid,datetime,date,bytes", "license": "MIT License", "maintainer": "", "maintainer_email": "", "name": "jsonextra", "package_url": "https://pypi.org/project/jsonextra/", "platform": "", "project_url": "https://pypi.org/project/jsonextra/", "project_urls": { "Homepage": "https://github.com/den4uk/jsonextra" }, "release_url": "https://pypi.org/project/jsonextra/0.3.2/", "requires_dist": [ "python-dateutil (<3,>=2.8.0)", "dateutils (==0.6.6)" ], "requires_python": ">=3.5", "summary": "JSON Extra | JSON that gives you extra datetime, uuid and bytes data types", "version": "0.3.2" }, "last_serial": 5765364, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "66c139f1685d9872a906d923bbfc329f", "sha256": "842e4e55a7495750ba62e4ce785bf35489f20bace3c4727bb3b68f8ed99a9b0e" }, "downloads": -1, "filename": "jsonextra-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "66c139f1685d9872a906d923bbfc329f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 4301, "upload_time": "2019-06-15T08:56:25", "url": "https://files.pythonhosted.org/packages/7f/42/629c08a33ae766674bcb2728f84083bd566b4376bbabf813fa8e7060177a/jsonextra-0.1.0-py3-none-any.whl" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "3cb45add3e83bbdb3a1fb75872ca6dbe", "sha256": "84bccfe3362c3cc11f20f581d2094f15b1480d35ecf7cb00ddf074d956a37db1" }, "downloads": -1, "filename": "jsonextra-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "3cb45add3e83bbdb3a1fb75872ca6dbe", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 3456, "upload_time": "2019-06-15T15:48:03", "url": "https://files.pythonhosted.org/packages/f9/a6/4839b1389d796fd8cac8537502064af6aaed7c217cc899b5cb350f4fd00c/jsonextra-0.2.0-py3-none-any.whl" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "d8b78a89827b2edbd8f649c75331cd93", "sha256": "2512dd89842a20b068fde382c9a6bac63a83dcc6317c537d880c81407087d19c" }, "downloads": -1, "filename": "jsonextra-0.2.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "d8b78a89827b2edbd8f649c75331cd93", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.5", "size": 4162, "upload_time": "2019-06-16T13:01:19", "url": "https://files.pythonhosted.org/packages/b3/84/3fd1b7b1ba469660a85123c28f780ce2950d6bd9a64281cb526e4f9afd01/jsonextra-0.2.1-py2.py3-none-any.whl" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "b80d5c3f3be776c913ad0f8fc79eb684", "sha256": "1bb08d95a48aa1873a8062f3139ad4c9a51c9ed9464a18e62254adb729e320e5" }, "downloads": -1, "filename": "jsonextra-0.3.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "b80d5c3f3be776c913ad0f8fc79eb684", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.5", "size": 4341, "upload_time": "2019-07-07T13:45:11", "url": "https://files.pythonhosted.org/packages/09/34/f594e9f66fdfc972972cca459f6912ee7efecf36fd7b829acdc8c223b07a/jsonextra-0.3.0-py2.py3-none-any.whl" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "6d99a5422ecf9d7e9b93e6d08e0f394c", "sha256": "39b9087ac18aea6fa79cde114bf6167aa21fc538f5766a4cc665539b11aea9ad" }, "downloads": -1, "filename": "jsonextra-0.3.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "6d99a5422ecf9d7e9b93e6d08e0f394c", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.5", "size": 4881, "upload_time": "2019-07-10T22:19:04", "url": "https://files.pythonhosted.org/packages/98/f3/be52d72deb49c9a1508d25550b6fd05ce1604dee05081ee148984e55ef9b/jsonextra-0.3.1-py2.py3-none-any.whl" } ], "0.3.2": [ { "comment_text": "", "digests": { "md5": "0713c85ca6930c435645f8fb08ba0adf", "sha256": "b072c201e0feaeeef2897e1f63421ff7e398655415881fccf2e1b98f6cf6617c" }, "downloads": -1, "filename": "jsonextra-0.3.2-py3-none-any.whl", "has_sig": false, "md5_digest": "0713c85ca6930c435645f8fb08ba0adf", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 5026, "upload_time": "2019-08-31T21:17:35", "url": "https://files.pythonhosted.org/packages/5b/b4/686b3b4b590c6cc6f0715e862b01ecb483ef1b3a22243af72564d11d99c4/jsonextra-0.3.2-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "0713c85ca6930c435645f8fb08ba0adf", "sha256": "b072c201e0feaeeef2897e1f63421ff7e398655415881fccf2e1b98f6cf6617c" }, "downloads": -1, "filename": "jsonextra-0.3.2-py3-none-any.whl", "has_sig": false, "md5_digest": "0713c85ca6930c435645f8fb08ba0adf", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 5026, "upload_time": "2019-08-31T21:17:35", "url": "https://files.pythonhosted.org/packages/5b/b4/686b3b4b590c6cc6f0715e862b01ecb483ef1b3a22243af72564d11d99c4/jsonextra-0.3.2-py3-none-any.whl" } ] }