I already have a json array like
var a = {
report: [
{
Name: \"Nitin\",
comment: [
{
Try like this JS FIDDLE DEMO
var results = {
report: [{
Name: "Nitin",
comment: [{
count: 0,
mName: "Feb"
}, {
count: 2,
mName: "Mar"
}],
view: [{
count: 1,
mName: "Feb"
}, {
count: 0,
mName: "Mar"
}],
rating: [{
count: 3,
mName: "Feb"
}, {
count: 2,
mName: "Mar"
}],
Place: "Vatakara"
}, {
Name: "Sachin",
comment: [{
count: 3,
mName: "Feb"
}, {
count: 1,
mName: "Mar"
}],
view: [{
count: 2,
mName: "Feb"
}, {
count: 1,
mName: "Mar"
}],
rating: [{
count: 0,
mName: "Feb"
}, {
count: 3,
mName: "Mar"
}],
Place: "Mumbai"
}]
};
/////////////////////////////////////////////////////////////////////
var innArr = [];
for (var i = 0; i < results.report.length; i++) {
for(var j=0;j<results.report[i].comment.length;j++)
{
innArr[innArr.length] = {
"Name": results.report[i].name,
"Month": results.report[i].comment[j].mName,
"comment": results.report[i].comment[j].count,
"rating": results.report[i].rating[j].count,
"view": results.report[i].view[j].count
};
}
}
alert(JSON.stringify(innArr));