title: Preparing a String to be used in Json
body: <p>I have a string where I need to use as the body of a JSON object. I know its possible that the data could have quotes in it, so I parse through to add an escape character to those instance of quotes.. like so:</p>
  
  <pre><code>string NewComment = comment.Replace("\"", "\\\"");
  </code></pre>
  
  <p>However, somehow on some edgecases, a quote still makes it through. I don't know if this is something with UTF or some other issue, But I am trying to find a function that would safely create a json compatible string, I figured there has to be something like this out there, or a regex way of doing so.</p>
  
  <p>Basically a TLDR is how to create a json syntax safe string from a c# string</p>