title: JSON value with apostrophe
body: <p>I have an element with a rel attribute that contains a JSON string, something like:</p>
  
  <pre><code>rel='{"id":"#id#","name":"#name#"}'
  </code></pre>
  
  <p>Then, in my javascript code, I use <code>$.parseJSON</code> to parse this data. This works correctly - besides for cases where <code>name</code> contains an apostrophe. I've tried using <code>jsStringFormat</code>, a coldfusion <code>replace</code> that replaces all single quotes with escaped single quotes, etc, but I can't seem to hit on a correct solution. I know this is probably simple, but how do I get the code to correctly pass values with apostropes/single quotes using json?</p>
  
  <p>This code works, but eliminates the apostrophes which I'd like to preserve:</p>
  
  <pre><code>rel='{"id":"#id#","name":"#replace(name,"'","","all")#"}'
  </code></pre>
  
  <p>This does not work:</p>
  
  <pre><code>rel='{"id":"#id#","name":"#replace(name,"'","\'","all")#"}'
  </code></pre>
  
  <p>Nor does:</p>
  
  <pre><code>rel='{"id":"#id#","name":"#replace(name,"'","\\\'","all")#"}'
  </code></pre>
  
  <p>Or:</p>
  
  <pre><code>rel='{"id":"#id#","name":"#replace(name,"'","&amp;quot;","all")#"}'
  </code></pre>
  
  <p>Or:</p>
  
  <pre><code>rel='{"id":"#id#","name":"#jsStringFormat(name)#"}'
  </code></pre>