0

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 ?

1
  • How to pass a json file as input in json2html.convert(json=input) ? Commented Apr 16, 2018 at 10:14

1 Answer 1

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.