title: psql insert json with double quotes inside strings
body: <p>I'm trying to insert <code>exiftool</code> generated JSON into postgresql via <code>psql</code> which appears valid.  It appears somehow that having the escaped single quote and the escaped double quote are not working properly.  I can't figure out how to properly escape the json. It appears that psql isn't handling the single quote escape properly as its booting the \" out to the psql instead of the query.</p>
  
  <p>Given this table</p>
  
  <pre><code>create table test (exif jsonb);
  </code></pre>
  
  <p>These work:</p>
  
  <pre><code>test=&gt; insert into test values ('{"a": 1, "b": "2"}');
  INSERT 0 1
  test=&gt; insert into test values ('{"a": 1, "b": "2\""}');
  INSERT 0 1
  test=&gt; select * from test;
       exif
  ----------------------
  {"a": 1, "b": "2"}
  {"a": 1, "b": "2\""}
  </code></pre>
  
  <p>But these don't</p>
  
  <pre><code>test=&gt; insert into test values ('{"a": 1, "b": "1\' 2\""}');
  Invalid command \""}');. Try \? for help.
  
  test=&gt; select '{"a": 1, "b": "1' 2\""}';
  Invalid command \""}';. Try \? for help.
  
  test=&gt; select E'{"a": 1, "b": "1' 2\""}';
  Invalid command \""}';. Try \? for help.
  
  test=&gt; select '{"a": 1, "b": "1\' 2\""}';
  Invalid command \""}';. Try \? for help.
  </code></pre>
  
  <p>Any suggestions?</p>