I am new to python,but I have managed to write a simple code to generate json data to html format through json2html module. json2html.convert(json=input),here when I pass the json node it is working file,but I should pass a json file created from my application as input to json2html to generate the html table format.How could I pass any json file as input to convert the file to html table ?
Asked
Active
Viewed 2,229 times
0
-
How to pass a json file as input in json2html.convert(json=input) ? – Rakesh Talari Apr 16 '18 at 10:14
1 Answers
1
You can try using json2table module, at least I did like that. The following code creates a html file with all json data table-structured.
from json2table import *
import json
data = open('YOURFILE.json','r')
jsonFile = data.read()
foo = json.loads(jsonFile)
build_dir = "LEFT_TO_RIGHT"
table_attr = {"style" : "width:100%", "class" : "table table-striped"}
html = convert(foo, build_direction=build_dir,table_attributes=table_attr)
with open("YOURFILE.html", "w") as ht:
ht.write(html)

Christian
- 76
- 3