JSFiddle - React, Tailwind, and code Playground
HTML
<div id="result"></div>
CSS
#result div {
margin-left: 40px;
}
JavaScript
var jsonObj = {
"status":"ok",
"user_id":24369,
"user_rights":{
"active":"Y",
"admin":"N",
"id":"240379",
"deals":{
"add":"D",
"view":"M",
"edit":"M",
"delete":"M",
"export":"M"
},
"contacts":{
"add":"D",
"view":"A",
"edit":"A",
"delete":"M",
"export":null
}
},
"switcher":{
"right":"DEAL_ADD",
"value":"D"
}
},
html = '';
console.log(jsonObj)
function json_dump(obj) {
for (var key in obj) {
html += '<div>' + key + ' => ';
if (typeof obj[key] === 'object') {
json_dump(obj[key]);
html += '</div>';
} else {
html += obj[key] + '</div>'
}
}
return html;
}
var result = json_dump(jsonObj);
document.getElementById('result').innerHTML = result;