title: Escape quotes within triple-quoted strings
body: <p>Where quotes withing JSON strings are not escaped but nested in triple-quotes e.g.</p>
  <pre><code>j0 = '[
    {
        &quot;A&quot; : &quot;no quoted bits&quot;
    },
    {
      &quot;A&quot; : &quot;&quot;&quot;this contains: &quot;quoted&quot; bits&quot;&quot;&quot;,
      &quot;B&quot; : &quot;no quoted bits&quot;
    },
    {
      &quot;A&quot; : &quot;no quoted bits&quot;,
      &quot;B&quot; : &quot;&quot;&quot;this contains: &quot;quoted&quot; and &quot;more quoted&quot; bits&quot;&quot;&quot;
    }
  ]'
  </code></pre>
  <p>reading into R will error e.g.</p>
  <pre><code>jsonlite::fromJSON(j0)
  #&gt; Error: parse error: after key and value, inside map, I expect ',' or '}'
  #&gt;            bits&quot;   },   {     &quot;A&quot; : &quot;&quot;&quot;this contains: &quot;quoted&quot; bits&quot;&quot;&quot;
  #&gt;                      (right here) ------^
  </code></pre>
  <p>I've cobbled together a hacky workaround</p>
  <pre><code>escape_triple_quoted = function(j){
    j_split = strsplit(j, '&quot;{3}')[[1]]
    f = seq_along(j_split) %% 2 == 0  # filter
    j_split[f] = gsub('&quot;', '\\\\&quot;', j_split[f])
    paste(j_split, collapse = '&quot;')
  }
  
  escape_triple_quoted(j0) |&gt; jsonlite::fromJSON()
  #&gt;                              A                                              B
  #&gt; 1               no quoted bits                                           &lt;NA&gt;
  #&gt; 2 this contains: &quot;quoted&quot; bits                                 no quoted bits
  #&gt; 3               no quoted bits this contains: &quot;quoted&quot; and &quot;more quoted&quot; bits
  # function for parsing strings where quotes are not escaped but nested inside triple-quotes
  </code></pre>
  <p>but it doesn't feel like best practice.  Is there a better approach?</p>