Good afternoon, can someone help me map this json in a javascript ?
[{
"header": {
"nav" : {"option1":"menu 1"}
}
}]
so that this stays this way
<header>
<nav>
<li></li>
</nav>
</header>
Good afternoon, can someone help me map this json in a javascript ?
[{
"header": {
"nav" : {"option1":"menu 1"}
}
}]
so that this stays this way
<header>
<nav>
<li></li>
</nav>
</header>
The truth is that, as the comrades comment, it is not very clear what you ask or how you get from the json to the html but, doing an exercise of imagination and assuming that you are not using any framework, to see if this is what you need:
Here is a small example to see if this is what you want:
var menus = [
{"option":"menu 1"},
{"option":"menu 2"},
{"option":"menu 3"},
{"option":"menu 4"}
];
var html="";
for (var i = 0; i < menus.length; i++) {
html=html+"<li>" + menus[i].option + "</li>";
}
document.getElementById("menu").innerHTML=html;
<html>
<head>
</head>
<body>
<header>
<nav>
<ul id="menu"></ul>
</nav>
</header>
</body>
</html>