title: Mysql not escaping backslashes and quotes the way they need to be
body: <p>I'm trying to insert a json document into Mysql. I know it's not great but there's nothing I can do about that at the moment.</p>
  
  <p>This is what my insert looks like:</p>
  
  <pre><code>insert into table_name (cid,def) values (1234, '{"field1": "field with \\\" char"}');
  </code></pre>
  
  <p>No matter what I do, what ends up being inserted is:</p>
  
  <pre><code>{"field1": "field with \\" char"}
  </code></pre>
  
  <p>But what I need is:</p>
  
  <pre><code>{"field1": "field with \" char"}
  </code></pre>
  
  <p>When I try:</p>
  
  <pre><code>insert into table_name (cid,def) values (1234, '{"field1": "field with \\" char"}');
  </code></pre>
  
  <p>It still ends up like this:</p>
  
  <pre><code>{"field1": "field with \\" char"}
  </code></pre>
  
  <p>For some reason, three backslashes and two backslashes both produce the same exact result: two backslashes being saved.</p>
  
  <p>When I use NO_BACKSLASH_ESCAPES, every backslash gets stored as a double backslash, which is also not what I need.</p>
  
  <p>If anyone has any ideas as to what may be going on, that would be fantastic. Everything I've found so far suggests that storing the field as \\\" should work, and intuitively that makes sense, but it is just not working.</p>
  
  <p>Update: it seems like the root issue is that no matter what I do, a double backslash simply does not get escaped to a single backslash. For some reason, it just treats the double backslash and a double backslash.</p>