display json code example
Example 1: how to display json data in html
function appendData(data) {
var mainContainer = document.getElementById("myData");
for (var i = 0; i < data.length; i++) {
var div = document.createElement("div");
div.innerHTML = 'Name: ' + data[i].firstName + ' ' + data[i].lastName;
mainContainer.appendChild(div);
}
}
Example 2: how to display json data in html
mainContainer.appendChild(div);
Example 3: online json viewer
Online JSON beautifier: https://codebeautify.org/jsonviewer
JSON pretty print in Python:
import json
your_json = '["foo", {"bar":["baz", null, 1.0, 2]}]'
parsed = json.loads(your_json)
print(json.dumps(parsed, indent=4, sort_keys=True))