{ "info": { "author": "Ryan Latture", "author_email": "ryan.latture@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "json2table\n==========\n\n|Build Status| |Coverage Status|\n\n.. |Build Status| image:: https://travis-ci.org/latture/json2table.svg?branch=master\n :target: https://travis-ci.org/latture/json2table\n.. |Coverage Status| image:: https://coveralls.io/repos/github/latture/json2table/badge.svg?branch=master\n :target: https://coveralls.io/github/latture/json2table?branch=master\n\nThis is a simple Python package that allows a JSON object to be converted to HTML. It provides a ``convert`` function that accepts a ``dict`` instance and returns a string of converted HTML. For example, the simple JSON object ``{\"key\" : \"value\"}`` can be converted to HTML via:\n\n.. code:: python\n\n >>> from json2table import convert\n >>> json_object = {\"key\" : \"value\"}\n >>> build_direction = \"LEFT_TO_RIGHT\"\n >>> table_attributes = {\"style\" : \"width:100%\"}\n >>> html = convert(json_object, build_direction=build_direction, table_attributes=table_attributes)\n >>> print(html)\n '
keyvalue
'\n\nThe resulting table will resemble\n\n+---------+-------+\n| **key** | value |\n+---------+-------+\n\nMore complex parsing is also possible. If a list of ``dict``'s provides the same list of keys, the generated HTML with gather items by key and display them in the same column.\n\n.. code:: json\n\n {\"menu\": {\n \"id\": \"file\",\n \"value\": \"File\",\n \"menuitem\": [\n {\"value\": \"New\", \"onclick\": \"CreateNewDoc()\"},\n {\"value\": \"Open\", \"onclick\": \"OpenDoc()\"},\n {\"value\": \"Close\", \"onclick\": \"CloseDoc()\"}\n ]\n }\n }\n\nOutput:\n\n+----------+--------------+----------------+-----------+\n| **menu** | **menuitem** | **onclick** | **value** |\n+ + +----------------+-----------+\n| | | CreateNewDoc() | New |\n+ + +----------------+-----------+\n| | | OpenDoc() | Open |\n+ + +----------------+-----------+\n| | | CloseDoc() | Close |\n+ +--------------+----------------+-----------+\n| | **id** | file |\n+ +--------------+----------------+-----------+\n| | **value** | File |\n+----------+--------------+----------------+-----------+\n\nIt might, however, be more readable if we were able to build the table from top-to-bottom instead of the default left-to-right. Changing the ``build_direction`` to ``\"TOP_TO_BOTTOM\"`` yields:\n\n+----------------+-----------+-------+-----------+\n| **menu** |\n+----------------+-----------+-------+-----------+\n| **menuitem** | **id**| **value** |\n+----------------+-----------+-------+-----------+\n| **onclick** | **value** | file | File |\n+----------------+-----------+ + +\n| CreateNewDoc() | New | | | \n+----------------+-----------+ + +\n| OpenDoc() | Open | | |\n+----------------+-----------+ + +\n| CloseDoc() | Close | | |\n+----------------+-----------+-------+-----------+\n\nTable attributes are added via the ``table_attributes`` parameter. This parameter should be a ``dict`` of ``(key, value)`` pairs to apply to the table in the form ``key=\"value\"``. If in our simple example before we additionally wanted to apply a class attribute of ``\"table table-striped\"`` we would use the following:\n\n.. code:: python\n\n >>> table_attributes = {\"style\" : \"width:100%\", \"class\" : \"table table-striped\"}\n\nand convert just as before:\n\n.. code:: python\n\n >>> html = convert(json_object, build_direction=build_direction, table_attributes=table_attributes)\n\nDetails\n-------\nThis module provides a single ``convert`` function. It takes as input the JSON object (represented as a Python ``dict``) and, optionally, a build direction and a dictionary of table attributes to customize the generated table: \n\n``convert(json_input, build_direction=\"LEFT_TO_RIGHT\", table_attributes=None)``\n\n**Parameters**\n\njson_input : dict\n\n JSON object to convert into HTML.\n\nbuild_direction : ``{\"TOP_TO_BOTTOM\", \"LEFT_TO_RIGHT\"}``, optional\n\n String denoting the build direction of the table. If ``\"TOP_TO_BOTTOM\"`` child\n objects will be appended below parents, i.e. in the subsequent row. If ``\"LEFT_TO_RIGHT\"``\n child objects will be appended to the right of parents, i.e. in the subsequent column.\n Default is ``\"LEFT_TO_RIGHT\"``.\n\ntable_attributes : ``dict``, optional\n\n Dictionary of ``(key, value)`` pairs describing attributes to add to the table. \n Each attribute is added according to the template ``key=\"value\"``. For example, \n the table ``{ \"border\" : 1 }`` modifies the generated table tags to include \n ``border=\"1\"`` as an attribute. The generated opening tag would look like \n ````. Default is ``None``.\n\n**Returns**\n\n``str``\n\n String of converted HTML.\n\nInstallation\n------------\nThe easiest method on installation is to use ``pip``. Simply run:\n\n::\n\n >>> pip install json2table\n\nIf instead the repo was cloned, navigate to the root directory of the ``json2table`` package from the command line and execute:\n\n::\n\n >>> python setup.py install\n\nTests\n-----\n\nIn order to verify the code is working, from the command line navigate to the ``json2table`` root directory and run:\n\n::\n\n >>> python -m unittest tests.test_json2table", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/latture/json2table/tarball/master", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/latture/json2table", "keywords": "json,HTML,convert,table", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "json2table", "package_url": "https://pypi.org/project/json2table/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/json2table/", "project_urls": { "Download": "https://github.com/latture/json2table/tarball/master", "Homepage": "https://github.com/latture/json2table" }, "release_url": "https://pypi.org/project/json2table/1.1.5/", "requires_dist": null, "requires_python": null, "summary": "Convert JSON to an HTML table", "version": "1.1.5" }, "last_serial": 2415884, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "8652b59881aa6b149560453d0718d1e0", "sha256": "e552e0499dd65abc223c72753fc6fe8d9cec3c5df55fd07eceea0c13356152ab" }, "downloads": -1, "filename": "json2table-1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "8652b59881aa6b149560453d0718d1e0", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7749, "upload_time": "2016-05-14T00:54:09", "url": "https://files.pythonhosted.org/packages/a8/62/b6dc6035e1356f42b1e7a6bcd0b4317af205b735981ea8dcd4a9f0e44ae4/json2table-1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "75f345c0dfd48b2eccd9211992ed4401", "sha256": "77c2d52d61e93058eca88f111f977ade0f9f3f02c341e424c64854dfd759b259" }, "downloads": -1, "filename": "json2table-1.0.tar.gz", "has_sig": false, "md5_digest": "75f345c0dfd48b2eccd9211992ed4401", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6072, "upload_time": "2016-05-14T00:54:21", "url": "https://files.pythonhosted.org/packages/c6/7f/e92fe7bf8e44c588b480b4036aefacb5252597825356962b634a2d58b5e3/json2table-1.0.tar.gz" } ], "1.1": [ { "comment_text": "", "digests": { "md5": "488a296945440eb15f2240ca2685c3a0", "sha256": "3e1009c706115603b450e0ecd5732a0a0dc3fd4f8bfcdc0f695e056c5af42091" }, "downloads": -1, "filename": "json2table-1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "488a296945440eb15f2240ca2685c3a0", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8687, "upload_time": "2016-05-14T06:55:07", "url": "https://files.pythonhosted.org/packages/67/f8/2919b96fd58952640a867428a8534f10fffcdee0dd818c9ac0aa514ae728/json2table-1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "bb3d17120803c1d11c46dcd8b97f1c6d", "sha256": "9ce605225026dd5d9c6a507c43f0df06e9f86b57878a526c76b807d0eaa0442f" }, "downloads": -1, "filename": "json2table-1.1.tar.gz", "has_sig": false, "md5_digest": "bb3d17120803c1d11c46dcd8b97f1c6d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6429, "upload_time": "2016-05-14T06:55:22", "url": "https://files.pythonhosted.org/packages/3b/af/bafc0a14f98d4382f7383a20a085e3c3442a0a4aef10fc1e08911c3c529a/json2table-1.1.tar.gz" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "85384c766db463e3c0c0a2e2f3a1a5a0", "sha256": "9aa29e6d6d36fd27e077ba2e09202d1e3bf0fc21d1d38315adcfc37332359962" }, "downloads": -1, "filename": "json2table-1.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "85384c766db463e3c0c0a2e2f3a1a5a0", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 8650, "upload_time": "2016-10-21T22:08:23", "url": "https://files.pythonhosted.org/packages/67/d8/cb9d72d4a7cb14086f5ee19b01d0b04729c8e2509157c3e75bbfe235f9d6/json2table-1.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3e3ecb6e099404be1e84dc73dc8e7a6b", "sha256": "fe9c88cd6033491e6813f33d4086568fcbf5cc85aebabd8c86785aa8c6bddab0" }, "downloads": -1, "filename": "json2table-1.1.1.tar.gz", "has_sig": false, "md5_digest": "3e3ecb6e099404be1e84dc73dc8e7a6b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6399, "upload_time": "2016-10-21T22:08:10", "url": "https://files.pythonhosted.org/packages/ee/9c/b4800bfac77dcd57f33a16fbca403221d3ff9c37ec5c71d1e32d01fc2449/json2table-1.1.1.tar.gz" } ], "1.1.4": [ { "comment_text": "", "digests": { "md5": "8ff19189de779f7fb6e13b88367c211d", "sha256": "92aef2de590098464fb6c9bd325dbbe5d5ce7609d0a8ae53b2946cfd8f9f1d30" }, "downloads": -1, "filename": "json2table-1.1.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "8ff19189de779f7fb6e13b88367c211d", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 8654, "upload_time": "2016-10-21T22:29:00", "url": "https://files.pythonhosted.org/packages/8e/18/d01abcf99baa2278694ac6698a3ec20e61f68221ca7544b58a603014c74b/json2table-1.1.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4a2d294f8824b32d8e2971676d7b04fa", "sha256": "68e5062cfd8f8594c87eeaa8ddd8cde128ee4572bebee49ea4fafe49a410eb71" }, "downloads": -1, "filename": "json2table-1.1.4.tar.gz", "has_sig": false, "md5_digest": "4a2d294f8824b32d8e2971676d7b04fa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6397, "upload_time": "2016-10-21T22:28:49", "url": "https://files.pythonhosted.org/packages/03/0e/1d28d65e2a07c1098499074ec2aef286ba218d75b98af21e74599701a073/json2table-1.1.4.tar.gz" } ], "1.1.5": [ { "comment_text": "", "digests": { "md5": "410dbda6a740e2c0b081cd04485197a8", "sha256": "d84eac9471f404f17c9ec1ca5935d7088917f669b3ba5cc5a027f865e7896356" }, "downloads": -1, "filename": "json2table-1.1.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "410dbda6a740e2c0b081cd04485197a8", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 8672, "upload_time": "2016-10-21T22:36:39", "url": "https://files.pythonhosted.org/packages/c0/20/93b122d0daec1cc728b6e6dde860615e81c2bf03fb05cad9e3c1899b3c11/json2table-1.1.5-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2dc545c230a987e59df50a1aeca55858", "sha256": "838e4c052276252fec7b0dbd10668258ce0997605888a250307bd6b124ae6d0a" }, "downloads": -1, "filename": "json2table-1.1.5.tar.gz", "has_sig": false, "md5_digest": "2dc545c230a987e59df50a1aeca55858", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6326, "upload_time": "2016-10-21T22:36:28", "url": "https://files.pythonhosted.org/packages/fe/f6/05039bd75d6ec8a07135bf97d6d11e92ab51e2939cd065bb6f7d0be46de5/json2table-1.1.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "410dbda6a740e2c0b081cd04485197a8", "sha256": "d84eac9471f404f17c9ec1ca5935d7088917f669b3ba5cc5a027f865e7896356" }, "downloads": -1, "filename": "json2table-1.1.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "410dbda6a740e2c0b081cd04485197a8", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 8672, "upload_time": "2016-10-21T22:36:39", "url": "https://files.pythonhosted.org/packages/c0/20/93b122d0daec1cc728b6e6dde860615e81c2bf03fb05cad9e3c1899b3c11/json2table-1.1.5-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2dc545c230a987e59df50a1aeca55858", "sha256": "838e4c052276252fec7b0dbd10668258ce0997605888a250307bd6b124ae6d0a" }, "downloads": -1, "filename": "json2table-1.1.5.tar.gz", "has_sig": false, "md5_digest": "2dc545c230a987e59df50a1aeca55858", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6326, "upload_time": "2016-10-21T22:36:28", "url": "https://files.pythonhosted.org/packages/fe/f6/05039bd75d6ec8a07135bf97d6d11e92ab51e2939cd065bb6f7d0be46de5/json2table-1.1.5.tar.gz" } ] }