title: Json encoding strings with spaces
body: <p>I'm working on a metabox class for wordpress, and specifically implementing the Media Uploading introduced in 3.5. To pass options between the metabox class and the media uploader I like to use json. The basic data structure I have is below (<code>$data_ar</code>).</p>
  
  <pre><code>Array
  (
      [uploader_title] =&gt; Upload or choose a video file
      [uploader_button] =&gt; Choose
      [allowed_mimes] =&gt; Array
          (
              [0] =&gt; application/x-shockwave-flash
              [1] =&gt; application/pdf
          )
  
      [show_icon] =&gt; 1
      [show_url] =&gt; 1
      [show_file_title] =&gt; 1
  )
  </code></pre>
  
  <p>The problem is that when doing a simple </p>
  
  <pre><code>echo '&lt;h1 id="stumped" data-stumped="'.json_encode($data_ar).'"&gt;test&lt;/h1&gt;';
  </code></pre>
  
  <p>results in the data attribute containing the json being malformed. The problem is the presence of any string within the array with spaces. Wrapping any sting values with spaces in double quotes does not help.</p>
  
  <p>Setting the data attribute via <code>jQuery.data()</code> works perfectly, but I cant use that as I have these form elements as repeaters, and the double jQuery calls breaks the repeaters.</p>
  
  <p>Talk about stumped. Any pointers on where I should be looking to sort this?</p>
  
  <p>Thanks.</p>