var json_object = [{
"attributes": {
"Code": "SGL",
"Total": "19421340.27"
},
"DayPrice": [{
"Date": "2016-07-22",
"Rate": "4900439.85"
}, {
"Date": "2016-07-23",
"Rate": "4845150.21"
}, {
"Date": "2016-07-24",
"Rate": "4845150.21"
}, {
"Date": "2016-07-25",
"Rate": "4830600"
}]
}, {
"attributes": {
"Code": "DBL",
"Total": "6473780.09"
},
"DayPrice": [{
"Date": "2016-07-22",
"Rate": "1633479.95"
}, {
"Date": "2016-07-23",
"Rate": "1615050.07"
}, {
"Date": "2016-07-24",
"Rate": "1615050.07"
}, {
"Date": "2016-07-25",
"Rate": "1610200"
}]
}, {
"attributes": {
"Code": "QUAD",
"Total": "6473780.09"
},
"DayPrice": [{
"Date": "2016-07-22",
"Rate": "1633479.95"
}, {
"Date": "2016-07-23",
"Rate": "1615050.07"
}, {
"Date": "2016-07-24",
"Rate": "1615050.07"
}, {
"Date": "2016-07-25",
"Rate": "1610200"
}]
}];
// generate the object for generating table easly
var res = {};
json_object.forEach(function(v, i) {
var code = v.attributes.Code; // get value of property code
v.DayPrice.forEach(function(v1) {
var date = v1.Date; // get date value from inner object
res[date] = res[date] || {}; // initialize object with date if not
res[date][code] = v1.Rate; // add code value
});
});
// genarate tr and td using generated object
$('#table').html($.map(res, function(v, i) { // iterate over the generated object
return $('<tr/>', { // generate tr
html: [$('<td/>', { // generate first column
text: i // set first column value as date (key)
}), $('<td/>', { // generate second column
html: $.map(v, function(i1, v1) { // iterate over inner ibject to generate second columnn content
return i1 + ':' + v1 + '(per room)'; // generate second column content
}).join('<br>') // seperate each line using br tag
})]
})
}))
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<table id="table" border=1></table>