title: Scala: how to pass HTML as JSON value?
body: <p>How to transfer HTML in JSON?
  According to <a href="https://en.wikipedia.org/wiki/JSON#Data_types.2C_syntax_and_example" rel="nofollow noreferrer">JSON validation rules</a> for <code>String</code>s we need to escape <code>"</code>:</p>
  
  <blockquote>
    <p>String: a sequence of zero or more Unicode characters. Strings are
    delimited with double-quotation marks and support a backslash escaping
    syntax.</p>
  </blockquote>
  
  <p>So the question is how to process html string, in order to pass it to JSON and get a valid JSON doc in the end?  </p>
  
  <p>Let's consider this html:</p>
  
  <pre><code>&lt;h1&gt;Document&lt;/h1&gt;
  &lt;p&gt;Hello, welcome to wonderful web!&lt;/p&gt;
  &lt;p&gt;Start from visiting &lt;a href="www.google.com"&gt;Google&lt;/a&gt;&lt;/p&gt;
  </code></pre>
  
  <p>Applying <code>.replace("\"", "\\\"")</code> to a <code>String</code> with html content in Scala does not work.</p>
  
  <p>I use <a href="https://github.com/spray/spray-json" rel="nofollow noreferrer">spray-json</a> <code>.parseJson</code> in order to validate the result.</p>