json2html, python: json data not converted to html
<p>I'm trying to format json data to html using json2html.
The json data look like this:</p>

<pre><code>json_obj = [{"Agent Status": "status1", "Last backup": "", "hostId": 1234567, "hostfqdn": "test1.example.com", "username": "user1"}, {"Agent Status": "status2", "Last backup": "", "hostId": 2345678, "hostfqdn": "test2.example.com", "username": "user2"}]
</code></pre>

<p>As already reported in post "<a href="http://stackoverflow.com/questions/38633629/json2html-not-a-valid-json-list-python">json2html not a valid json list python</a>", to make the code works, the json parameter must be a dictionary and not a list, so I'm calling it that way:</p>

<pre><code>json_obj_in_html = json2html.convert(json = { "data" : json_obj })
</code></pre>

<p>However it does not format the json data to html only the first level of dictionary { "data" : json_obj }:</p>

<pre><code>print json_obj_in_html
&lt;table border="1"&gt;&lt;tr&gt;&lt;th&gt;data&lt;/th&gt;&lt;td&gt;[{"Agent Status": "status1", "Last backup": "", "hostId": 1234567, "hostfqdn": "test1.example.com", "username": "user1"}, {"Agent Status": "status2", "Last backup": "", "hostId": 2345678, "hostfqdn": "test2.example.com", "username": "user2"}]&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
</code></pre>

<p>Note that the <strong>online</strong> convert tool provides the right output: <a href="http://json2html.varunmalhotra.xyz/" rel="nofollow">http://json2html.varunmalhotra.xyz/</a></p>

<pre><code>&lt;table border="1"&gt;&lt;tr&gt;&lt;th&gt;data&lt;/th&gt;&lt;td&gt;&lt;ul&gt;&lt;table border="1"&gt;&lt;tr&gt;&lt;th&gt;Agent Status&lt;/th&gt;&lt;td&gt;status1&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;th&gt;Last backup&lt;/th&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;th&gt;hostId&lt;/th&gt;&lt;td&gt;1234567&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;th&gt;hostfqdn&lt;/th&gt;&lt;td&gt;test1.example.com&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;th&gt;username&lt;/th&gt;&lt;td&gt;user1&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;table border="1"&gt;&lt;tr&gt;&lt;th&gt;Agent Status&lt;/th&gt;&lt;td&gt;status2&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;th&gt;Last backup&lt;/th&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;th&gt;hostId&lt;/th&gt;&lt;td&gt;2345678&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;th&gt;hostfqdn&lt;/th&gt;&lt;td&gt;test2.example.com&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;th&gt;username&lt;/th&gt;&lt;td&gt;user2&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/ul&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
</code></pre>

<p>Any help would be very welcome.</p>

<p>My list of dictionaries <code>anomaly_list</code> was already in a json format, so trying to convert it using <code>json.dumps(anomaly_list, sort_keys=True)</code> was turning into a string, which was not what I wanted.
I solved the issue by leaving my list of dictionaries as it is and this code now works:</p>

<pre><code>json_obj_in_html = ''
for j in anomalies_list:
    json_obj_in_html += json2html.convert(json = j)
</code></pre>

<p>It outputs what I wanted.</p>

<p>@gus42: thanks, your feedback made me understand where the real pb was.</p>

python html json json2html