-
Notifications
You must be signed in to change notification settings - Fork 2
/
json2html.py
32 lines (30 loc) · 1.44 KB
/
json2html.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# -*- coding: utf-8 -*-
"""
/***************************************************************************
Name : Json2HTML
Description : Function to get dictionary(json) and create HTML how a list
Date : June, 2018
copyright : (C) 2018 by Luiz Motta
email : [email protected]
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
"""
def getHtmlTreeMetadata(value, html):
if isinstance( value, dict ):
html += "<ul>"
for key, val in sorted( iter( value.items() ) ):
if not isinstance( val, dict ):
html += "<li>%s: %s</li> " % ( key, val )
else:
html += "<li>%s</li> " % key
html = getHtmlTreeMetadata( val, html )
html += "</ul>"
return html
return html