title: Serialize complex form to JSON object using jQuery
body: <p>I've been searching for hours for this and haven't found an answer.
  Please read through the whole question before flaming! :)</p>
  
  <p>I have a form similar to this:</p>
  
  <pre><code>&lt;form id="sample"&gt;
   &lt;input name="name" type="text" value="name value" /&gt;
  
   &lt;input name="phone[0][type]" type="text" value="cell" /&gt;
   &lt;input name="phone[0][number]" type="text" value="000" /&gt;
  
   &lt;input name="phone[1][type]" type="text" value="home" /&gt;
   &lt;input name="phone[1][number]" type="text" value="111" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>And need to be able to serialize it to this:</p>
  
  <pre><code>{
   name: 'name value',
  
   phone: [
    {
     type: 'cell',
     number: '000'
    },
    {
     type: 'home',
     number: '111'
    }
   ]
  }
  </code></pre>
  
  <p>I have tried most answers on SO including jquery-json libraries and most of them return something like this:</p>
  
  <pre><code>{
   'name': 'name value',
   'phone[0][type]': 'cell',
   'phone[0][number]': '000',
   'phone[1][type]': 'home',
   'phone[1][number]': '111',
  }
  </code></pre>
  
  <p>This is something <strong>I cannot use</strong>! :P</p>
  
  <p>Thanks everyone in advance.</p>