title: How do I wrap my serialized JSON string in 'single quotes'
body: <p>I have a javascript object called <code>blocki</code> that I want to serialize and update using a rest API. So I call:</p>
  
  <pre><code>JSON.stringify(blocki)
  </code></pre>
  
  <p>And that gives me this string:</p>
  
  <pre><code>"{"name":"Updated Blocki","bounds":{"x":"2em","y":"2em","w":"8em","h":"12em"}}"
  </code></pre>
  
  <p>That is almost what I need, except the doubly quoted string should have single quotes on the outside, like so:</p>
  
  <pre><code>'{"name":"Updated Blocki","bounds":{"x":"2em","y":"2em","w":"8em","h":"12em"}}'
  </code></pre>
  
  <p>According to examples on <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/JSON/stringify" rel="noreferrer">MDN JSON.stringify</a> it should return an string wrapped in single quotes. But when I try the same example in that page, I get string wrapped in double quotes. For instance, when I type <code>JSON.stringify({})</code> in Firefox and chrome console, I get back <code>"{}"</code> instead of <code>'{}'</code>. </p>
  
  <p>How can I properly serialize my Javascript object so the outer quotes are: <code>'</code>. Again, this string is an example of what I want to achieve:</p>
  
  <pre><code>'{"name":"Updated Blocki","bounds":{"x":"2em","y":"2em","w":"8em","h":"12em"}}'
  </code></pre>
  
  <p>Ideally, I would like to learn an nice way to serialize the object instead of having to modify the string after serialization.</p>
  
  <p>Edit: 
  The reason I think I need to do this is that the API I am working with is somehow not happy when the string is wrapped in double quotes. For example when I do</p>
  
  <pre><code>curl -i -H "Accept: application/json" -H "Content-type: application/json" -X PUT -d "{"name":"Updated Blocki","bounds":{"x":"2em","y":"2em","w":"8em","h":"12em"}}" 'http://localhost:3000/api/blockies/17'
  </code></pre>
  
  <p>The request fails and server gives a parsing error. However when I try:</p>
  
  <pre><code>curl -i -H "Accept: application/json" -H "Content-type: application/json" -X PUT -d '{"name":"Updated Blocki","bounds":{"x":"2em","y":"2em","w":"8em","h":"12em"}}' 'http://localhost:3000/api/blockies/17'
  </code></pre>
  
  <p>The put request goes through successfully and the object is updated.</p>