I've a trouble to parse JSON object to an html table. Basically my JSON data [EDITED] comes through looking like this:
[
{
'category': 'Automotive (Motor)',
'month':8,
'month_now':'Aug',
'year':2018,
'lists':{
'total':1,
'price':591600
}
},
{
'category': 'Health',
'month_now':'Aug',
'month':8,
'year':2018,
'lists':{
'total':21,
'price':14448600
}
}
]
I want to create a table like this:

I want to add months start from Jan to Des, with null data if every month has no total value.
I have read a lot about the JSON format and my knowledge is very limited and I need help -__-
I was trying, here's my code :
$(document).ready(function () {
var json = [{'category': Automotive (Motor),'month': 8, 'month_now': 'Aug', 'year': 2018, 'lists': {'total': 1, 'price': 591600}}, {'category': Health, 'month_now': 'Aug', 'month': 8, 'year': 2018, 'lists': {'total': 21, 'price': 14448600}}];
var tr;
for (var i = 0; i < json.length; i++) {
tr = $('<tr/>');
tr.append("<td>" + json[i].category + "</td>");
tr.append("<td>" + json[i].month + "</td>");
tr.append("<td>" + json[i].lists + "</td>");
$('table').append(tr);
}
});
Here's the html :
<table>
<tr>
<th>Category</th>
<th>Month</th>
<th>Total</th>
</tr>
</table>