JSFiddle - React, Tailwind, and code Playground
by Jeremy Bolanos
HTML
<div id="message"></div>
<table border="1" cellspacing="0" cellpadding="2">
<thead>
<tr>
<th>Name</th>
<th>KPI 1</th>
<th>KPI 2</th>
<th>KPI 3</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
CSS
div#message {
font:normal 14px/16px Arial, sans-serif;
margin-bottom: 10px;
}
table {
font:normal 14px/14px Arial, sans-serif;
}
table td, table th {
min-width: 120px;
}
JavaScript
// JSON
var data = {
"returnCode": {
"message": "Success",
"code": 0
},
"rollupData": [{
"kpiData": [0.32542455, 0.32869688, 0.33081105],
"kpiId": 301,
"rttSystem": "levdort",
"rollupName": "California",
"rollupType": "market"
}, {
"kpiData": [0.2263383, 0.19693609, 0.20306443],
"kpiId": 301,
"rttSystem": "levdort",
"rollupName": "Oklahoma",
"rollupType": "market"
}],
"kpiName": "FCA%",
"lastMinute": "2013-04-19 17:40:00"
};
var obj = JSON.parse(JSON.stringify(data));
if(obj.returnCode.code == 0){
alert('returnCode: ', obj.returnCode.code);
console.log('rollupData.lastMinute: ', obj.lastMinute);
$.each(obj.rollupData, function(p){
console.log('rollupData.kpiData: ', this['kpiData']);
$.each(this['kipData'], function(){
});
});
}