title: json_encode not preserving order
body: <p>I have a multi dimensional array, in PHP:</p>
  
  <pre><code>Array
  (
  [1] =&gt; Array
      (
          [19] =&gt; Array
              (                    
                  [type] =&gt; 2
              )            
          [6] =&gt; Array
              (                    
                  [type] =&gt; 4
              )
          [12] =&gt; Array
              (                    
                  [type] =&gt; 3
              )
      )
  
  )
  </code></pre>
  
  <p>When i json_encode this array in javascript via:</p>
  
  <pre><code> var jsonArray = &lt;?php echo json_encode($above_array); ?&gt;;
  </code></pre>
  
  <p>i get:</p>
  
  <pre><code> Object
   (
   [1] =&gt; Object
   (
      [6] =&gt; Object
          (                    
              [type] =&gt; 2
          )
      [12] =&gt; Object
          (                    
              [type] =&gt; 4
          )
      [19] =&gt; Object
          (                    
              [type] =&gt; 3
          )
  )
  
  )
  </code></pre>
  
  <p>I want to preserve the first order and not the second one by id.</p>