I am trying to parse nested JSON objects inside my html div. I am trying to get the TITLE for each object. I want it to be as DRY (don't repeat yourself) as possible so whenever I add a new object to the json It will automatically parse the object inside the div.
I don't know if this is the correct syntax for this
Object.keys(booklist.Bible)[1].Title
when I try to use this code it returns undefined.
<script>
var booklist = {
"Bible":{
"ARV":{"Title":"American Revised Version", "Author":"Unknown", "Icon":"ARV.png"},
"KJV":{"Title":"King James Version", "Author":"King James", "Icon":"KJV.png"},
},
"Bible Commentary":{
"DR":{"Title":"The Prophecies of Daniel and the Revelation by Uriah Smith", "Author":"Uriah Smith", "Icon":"DR.png"},
"EGWBC":{"Title":"Ellen G. White Bible Commentary", "Author":"Ellen G. White", "Icon":"EGWBC.png"}
},
var contents = Object.keys(booklist.Bible)[0];
var catList = document.getElementById('contents');
var category = document.createElement('div');
category.innerHTML='<div class="row">'+
'<div class="inline ui-block-a">'+
'<img class="thumbs" src="images/default.png">'+
'</div>'+
'<div class="inline ui-block-b">'+
'<h4>'+Object.keys(booklist.Bible)[1].Title+'</h4>'+
'<span class="subs"></span>'+
'</div>'+
'<div class="inline ui-block-c">'+
'<h4></h4>'+
'<span class="subs">Author</span>'+
'</div>'+
'</div><hr>';
catList.appendChild(category);
</script>