title: simplify JSON output from a JavaScript Object
body: <p>this is my first post. 
  I'm quite new to JavaScript Objects and I spent a day trying to figure out but I'm still stuck... I hope someone can give me a tip.</p>
  
  <p>Basically I have 2 or more form that I need to serialize and send data via ajax call.</p>
  
  <p>I have these forms:</p>
  
  <pre><code>&lt;form class="lang_block"&gt;
  
      &lt;fieldset&gt;
  
          &lt;legend&gt;it&lt;/legend&gt;
  
          &lt;input name="language" value="Italiano" type="text"&gt;
          &lt;input name="data" value="data_it" type="text"&gt;
          &lt;input name="temp" value="temp_it" type="text"&gt;
  
      &lt;/fieldset&gt;
  
  &lt;/form&gt;
  
  &lt;form class="lang_block"&gt;
  
      &lt;fieldset&gt;
  
          &lt;legend&gt;en&lt;/legend&gt;
  
          &lt;input name="language" value="English" type="text"&gt;
          &lt;input name="data" value="data_en" type="text"&gt;
          &lt;input name="temp" value="temp_en" type="text"&gt;
  
      &lt;/fieldset&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p>And and this JavaScript function:</p>
  
  <pre><code>function ConvertFormToJSON(target_form)
      {
          var form = $(target_form);
  
          var arr = [];
  
          form.each(function()
          {
              var obj = {};
  
              var sr = $(this).serializeArray();
  
              obj = $.each(sr, function()
              {
                  sr[this.name] = this.value;
              });
  
              arr.push(obj);
           });
  
          return JSON.stringify(arr);
      }
  
      ConvertFormToJSON('.lang_block');
  </code></pre>
  
  <p>The Output :</p>
  
  <pre><code>"[
      [
          {
              "name": "language",
              "value": "Italiano"
          },
          {
              "name": "data",
              "value": "data_it"
          },
          {
              "name": "temp",
              "value": "temp_it"
          }
      ],
      [
          {
              "name": "language",
              "value": "English"
          },
          {
              "name": "data",
              "value": "data_en"
          },
          {
              "name": "temp",
              "value": "temp_en"
          }
      ]
  ]"
  </code></pre>
  
  <p>The output I'd like to achieve:</p>
  
  <pre><code>"[
  
      {
          "language": "Italiano",
          "data": "data_it",
          "temp": "temp_it",
      },
  
      {
          "language": "English",
          "data": "data_en",
          "temp": "temp_en",
      }
  
  ]"
  </code></pre>