Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Features

* Generated table can be provided some ``attributes`` explicitly. Eg. giving an ``id``, ``class`` or any ``data-*`` attribute.
* Python 3 compatible
* Can be used as a library in your code base or called from command line

Live Demo
----------
Expand Down Expand Up @@ -195,6 +196,18 @@ Output:

<table border="1"><tr><th>glossary</th><td><table border="1"><tr><th>GlossDiv</th><td><table border="1"><tr><th>GlossList</th><td><table border="1"><tr><th>GlossEntry</th><td><table border="1"><tr><th>GlossDef</th><td><table border="1"><tr><th>GlossSeeAlso</th><td><ul><li>GML</li><li>XML</li></ul></td></tr><tr><th>para</th><td>A meta-markup language, used to create markup languages such as DocBook.</td></tr></table></td></tr><tr><th>GlossSee</th><td>markup</td></tr><tr><th>Acronym</th><td>SGML</td></tr><tr><th>GlossTerm</th><td>Standard Generalized Markup Language</td></tr><tr><th>Abbrev</th><td>ISO 8879:1986</td></tr><tr><th>SortAs</th><td>SGML</td></tr><tr><th>ID</th><td>SGML</td></tr></table></td></tr></table></td></tr><tr><th>title</th><td>S</td></tr></table></td></tr><tr><th>title</th><td>example glossary</td></tr></table></td></tr></table>

**Example 6:**

.. code-block:: bash

echo '{"key":"value"}'|json2html

Output:

.. code-block:: bash

<table border="1"><tr><th>key</th><td>value</td></tr></table>

Tests
------

Expand Down
12 changes: 12 additions & 0 deletions json2html/jsonconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,15 @@ def convert_object(self, json_input):
return converted_output

json2html = Json2Html()

def main():
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('infile', nargs='?', type=argparse.FileType('r'),
default=sys.stdin)
args = parser.parse_args()
data = args.infile.read()
print(json2html.convert(json = data))

if __name__ == "__main__":
main()
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: Implementation :: CPython',
],
entry_points = {
'console_scripts': ['json2html = json2html:main']
}
)