JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://underscorejs.org/underscore.js"></script>
JavaScript
var test = {
"r": [{
"IsDefault": false,
"re": {
"Name": "Depo"
},
"Valid": "Oct8, 2013",
"Clg": [{
"Name": "james",
"Rate": 0.05
}, {
"Name": "Jack",
"Rate": 0.55
}, {
"Name": "Mcd",
"Rate": 0.01,
}],
},
{
"IsDefault": false,
"re": {
"Name": "Depo"
},
"Valid": "Oct8, 2013",
"Clg": [{
"Name": "james",
"Rate": 0.05
}, {
"Name": "Jack",
"Rate": 0.55
}, {
"Name": "Mcd",
"Rate": 0.01,
}],
},
{
"IsDefault": false,
"re": {
"Name": "Depo"
},
"Valid": "Oct8, 2013",
"Clg": [{
"Name": "james",
"Rate": 0.05
}, {
"Name": "Jack",
"Rate": 0.55
}, {
"Name": "Mcd",
"Rate": 0.01,
}],
}]
};
loadFromJson1 = function (input)
// here is the problem, the 'input' is not an array object so it is not going to IF condition of the isArray method. Hence i am trying to convert into array object.
{
var resArray = $.map(input, function (value, index) {
return [value];
});
console.log("resArray:" + resArray);
if (_.isArray(resArray)) {
console.log("Inside array function");
//var rcollect = new rateCollection();
_.each(resArray, function (modelData) {
//rcollect.add(modelData);
});
// return rcollect;
}
//return new rateModel({
// names: resArray.Name,
// rates: resArray.Rate
//});
};
var tablesResult = loadFromJson1(test.r[0].Clg);