title: Convert json format to another json format by AngularJS
body: <p>I'm trying to implement a questionnaire with angularjs,So I have the following response array ,I need to convert this object array to json format like the following output, So How can I convert object array to json format?</p>
  
  <pre><code> var response=[{"questiongroup":1,"question":1,"response":"response1"},
                       {"questiongroup":1,"question":2,"response":"response2"},
                       {"questiongroup":1,"question":3,"response":"response3"},
                       {"questiongroup":1,"question":4,"response":"response4"},
                       {"questiongroup":1,"question":5,"response":"response5"},
                       {"questiongroup":2,"question":6,"response":"response6"},
                       {"questiongroup":2,"question":7,"response":"response7"},
                       {"questiongroup":2,"question":8,"response":"response8"},
                       {"questiongroup":2,"question":9,"response":"response9"},
                       {"questiongroup":2,"question":10,"response":"response10"}];
  </code></pre>
  
  <p>desired output</p>
  
  <pre><code>   {"questiongroups": [
                         {
                           "questiongroup": 1,
                           "question": [
                             {
                               "question": 1,
                               "response":"response1"
                             },
                             {
                               "question": 2,
                               "response":"response2"
                              },
                              {
                               "question": 3,
                               "response":"response3"
                               },
                              {
                               "question": 4,
                               "response":"response4"
                                },
                               {
                                "question": 5,
                                "response":"response5"
                               }]
                           },
                           {
                               "questiongroup": 2,
                               "question": [
                                 {
                                   "question": 6,
                                   "response":"response6"
                                 },
                                 {
                                   "question": 7,
                                   "response":"response7"
                                  },
                                  {
                                   "question": 8,
                                   "response":"response8"
                                   },
                                  {
                                   "question": 9,
                                   "response":"response9"
                                    },
                                   {
                                    "question": 10,
                                    "response":"response10"
                                   }]
                               }
                           ]
                      }
  </code></pre>