/* mostrar valores de JSON files dentro de un html */ var json = { "name": "John", "age": 30, "cars": [ { "name": "Ford", "models": ["Fiesta", "Focus", "Mustang"] }, { "name": "BMW", "models": ["320", "X3", "X5"] }, { "name": "Fiat", "models": ["500", "Panda"] } ] } var text = ""; var i; for (i = 0; i < json.cars.length; i++) { text += json.cars[i].name + "<br>"; } document.getElementById("demo").innerHTML = text;
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter