0

我有这样的json数据。

 var data=    [
{"categoryName":"VPN", "INCIDENT_ID":"IN006336", "DESCRIPTION":"vpn not complaint",    
"maximumHit":"2"},


{"categoryName":"VPN", "INCIDENT_ID":"IN006112", "DESCRIPTION":"VPN issues asked to   
reinstall vpn client", "maximumHit":"2"}, 


{"categoryName":"VPN", "INCIDENT_ID":"IN011902", "DESCRIPTION":"vpn installation link- 
itldrive", "maximumHit":"2"}];

并想要以下格式的数据

 var json2 =
   {
         "name": "Network Issue",
         "children": [
          {
           "name": "DESCRIPTION", 
           "children": 

            [
              {"name": "vpn not complaint"},
              {"name": "VPN issues asked to reinstall vpn client"},
              {"name": "vpn installation link- itldrive"}
             ]
          },

          {
           "name": "INCIDENT_ID",
           "children": [

            {"name": "IN006336"},
            {"name": "IN006112"},
                {"name": "IN006112"}
           ]
          },

          {
           "name": "categoryName",
           "children": [
               {"name": "VPN"},
            {"name": "VPN"},
                {"name": "VPN"}
           ]
          }
         ]
        }
4

1 回答 1

0

也许像这样?

var str = JSON.stringify(obj, undefined, 2);
于 2013-08-01T09:38:38.583 回答