{ "info": { "author": "Thomas Smith", "author_email": "smithtg@ncbi.nlm.nih.gov", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: Public Domain", "Programming Language :: Python :: 3" ], "description": "jsonfile - incrementally generate JSON\n\n``pip install jsonfile`` - `PyPI link `_\n\nIncrementally means that, in most places, you can either send in a complete Python\nobject, or build it a piece at a time. For example, let's build the JSON structure\n``[3, {\"cool\": true, \"awesome\": [1,2,3,4,5]}]``::\n\n >>> import jsonfile\n >>> jp = jsonfile.JsonProto()\n >>> jp.start_list()\n '['\n >>> jp.list_item(3)\n '3'\n >>> jp.start_dict()\n ',{'\n >>> jp.dict_item('cool', True)\n '\"cool\":true'\n >>> jp.dict_key('awesome')\n ',\"awesome\"'\n >>> jp.dict_value([1,2,3,4,5])\n ':[1, 2, 3, 4, 5]'\n >>> jp.finish_all()\n '}]'\n\nThat used the ``JsonProto`` object, a *sans-io* version that just returns the\ntext that you should write to your output. If you are writing to a file in a\nnormal synchronous context, you could also use the ``JsonWriter`` object, it\nwill be slightly more convenient::\n\n >>> import io\n >>> dest = io.StringIO()\n >>> import jsonfile\n >>> jw = jsonfile.JsonWriter(dest)\n >>> jw.start_list()\n >>> jw.list_item(3)\n >>> jw.list_item({'things': 'stuff'})\n >>> jw.start_dict()\n >>> jw.dict_item('cool', True)\n >>> jw.dict_key('awesome')\n >>> jw.dict_value([1,2,3,4,5])\n >>> jw.finish_all()\n >>> dest.getvalue()\n '[3,{\"things\": \"stuff\"},{\"cool\":true,\"awesome\":[1, 2, 3, 4, 5]}]'\n\n\nBecause the underlying ``JsonProto`` doesn't do IO, it should be easy to make a\nversion of ``JsonWriter`` that works well in an async context.\n\nMany kinds of errors are caught: having more than one object at the root level\nof a file, using a list item in a dictionary, etc.\n\nTODO:\n\n- Allow specifying your own JSONEncoder to use on complete objects.\n- Do indentation.\n- Implement an ``AsyncJsonWriter``\n- Better tests for preventing illegal JSON from being generated (e.g. lists as\n keys).\n- Python 2 support?", "description_content_type": null, "docs_url": null, "download_url": null, "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/tgs/jsonfile", "keywords": null, "license": null, "maintainer": null, "maintainer_email": null, "name": "jsonfile", "package_url": "https://pypi.org/project/jsonfile/", "platform": null, "project_url": "https://pypi.org/project/jsonfile/", "project_urls": { "Homepage": "https://github.com/tgs/jsonfile" }, "release_url": "https://pypi.org/project/jsonfile/1.0.1/", "requires_dist": [ "enum34; python_version < '3.4'" ], "requires_python": ">=3", "summary": "jsonfile - incrementally write files in JSON format.", "version": "1.0.1" }, "last_serial": 2522039, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "c5f2dc9bb685b2c2f5fc53592803edf8", "sha256": "5ad1f9235607e50d66024017a28c863f068270384710c496d3c8c74048f771a3" }, "downloads": -1, "filename": "jsonfile-1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "c5f2dc9bb685b2c2f5fc53592803edf8", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5700, "upload_time": "2016-12-15T20:44:33", "url": "https://files.pythonhosted.org/packages/b9/93/0ab67dfc5f3b21e73eaf205756ca33ae1d21d9573be96bfad9a3d0525dd1/jsonfile-1.0-py3-none-any.whl" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "8d9904f86cc7252fb3a192653ddc3830", "sha256": "3049873d312d9bda145ec5cb75c946a954ff57bdbaa01c0a18f13e7d1171815a" }, "downloads": -1, "filename": "jsonfile-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "8d9904f86cc7252fb3a192653ddc3830", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 5838, "upload_time": "2016-12-15T21:02:51", "url": "https://files.pythonhosted.org/packages/06/46/72ce5521395db030727ea32d3f9a5a3019ad4622b3e1f3469b59cdb3ab7a/jsonfile-1.0.1-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "8d9904f86cc7252fb3a192653ddc3830", "sha256": "3049873d312d9bda145ec5cb75c946a954ff57bdbaa01c0a18f13e7d1171815a" }, "downloads": -1, "filename": "jsonfile-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "8d9904f86cc7252fb3a192653ddc3830", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 5838, "upload_time": "2016-12-15T21:02:51", "url": "https://files.pythonhosted.org/packages/06/46/72ce5521395db030727ea32d3f9a5a3019ad4622b3e1f3469b59cdb3ab7a/jsonfile-1.0.1-py3-none-any.whl" } ] }