OMGitzMidgar OMGitzMidgar - 2 years ago 1766
JSON Question

Converting json to html table in python

So I've been using the json library for python to get data from JSON files using python.

infoFromJson = json.loads(jsonfile)

I fully understand how to work with json files in python. However, I am trying to find a way to format JSON format in a nice way.

I prefer to convert the JSON into a nested HTML table format.

I actually found json2html for python, which does exactly what I just described.
However, it does not actually output anything when I run the script they provide.

Has anyone had experience with this tool? Or does anyone have suggestions for alternatives?

Answer Source

Try the following:

infoFromJson = json.loads(jsonfile)
print json2html.convert(json = infoFromJson)

The result from json2html.convert is a string.

if you dont have json2html module

$ pip install json2html

more example are here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download