How to convert json from one format to another?

后端 未结 1 828
迷失自我
迷失自我 2021-01-16 01:41

I already have a json array like

var a = {
    report: [ 
        {
            Name: \"Nitin\",
            comment: [
                {
                           


        
1条回答
  •  清酒与你
    2021-01-16 01:57

    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

    0 讨论(0)
提交回复
热议问题