title: Java 1.4 String.replaceAll issue with single quote
body: <p>I've got a string value coming from a database that has to be put into JSON, but the value can contain single and double quotes. Sounds easy enough, right? Well, apparently not in Java 1.4.2. Don't get me started on why it has to be 1.4.2, I inherited this from another developer and we can't update this project yet due to factors beyond my control. :)</p>
  
  <p>So, I have tried all of these (and lots of others just to see the result):</p>
  
  <pre><code>"sample user's string".replaceAll("'", "\'")      // returns "sample user's string"
  "sample user's string".replaceAll("'", "\\'")     // returns "sample user's string"
  "sample user's string".replaceAll("'", "\\\'")    // returns "sample user's string"
  "sample user's string".replaceAll("'", "\\\\'")   // returns "sample user\\'s string"
  "sample user's string".replaceAll("'", "%%")      // returns "sample user%%s string"
  </code></pre>
  
  <p>All I want is <code>sample user\'s string</code>, what am I doing wrong? Too bad 1.4.2 doesn't have the String.replace(String,String) function.</p>
  
  <p><strong>Edit</strong>: We are using the <code>json-simple</code> JSON library and I was looking at the output of the above commands in the resultant JSON string. I added additional debug info to see the value before the JSON gets output and it looks like the above commands really are working, but the <code>json-simple</code> library is stripping the escape chars out.</p>
  
  <p>So, what I'm seeing is:</p>
  
  <pre><code>"sample user's string".replaceAll("'", "\\\\'")    // sample user\'s string
  myJSONObject.put("value", "sample user's string".replaceAll("'", "\\\\'")) // sample user\\'s string"
  myJSONObject.put("value", "sample user's string") // sample user's string
  </code></pre>
  
  <p>So it looks like the library is not doing its job quite as expected. Does anyone that has used <code>json-simple</code> know of a workaround for this?</p>