title: How to escape HTML in JSON
body: <p>I'm wondering how can I escape HTML code in JSON ? I'm using Jackson as my JSON mapper.</p>
  
  <p>In my content I have various characters: tags, single quotes, double quotes, new lines character (\n), tabs etc. I tried to use CharacterEscapes class, but with no results.</p>
  
  <p>My JSON response blows up after using CharacterEscapes. I tried to escape it manually, but also without any results.</p>
  
  <p>So the question is, lets say that we have:</p>
  
  <pre><code> &lt;p&gt;Some text&lt;/p&gt;\n&lt;p&gt;"SomeText"&lt;/p&gt;
  </code></pre>
  
  <p>How can I send it back to browser as value of the JSON object?</p>
  
  <p><strong>UPDATE:</strong>
  Input is:</p>
  
  <pre><code>{
      "code": {
      "num": 12
  },
      "obj": {
          "label": "somelabel",
          "order": 1
      },
      "det": {
          "part": "1",
          "cont": true
      },
       "html": "&lt;p&gt;Mine text&lt;/p&gt;"
  }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>{
      "code": {
      "num": 12
  },
  "obj": {
      "label": "somelabel",
      "order": 1
  },
  "det": {
      "part":"1",
      "cont": true
  },
  "html":{"code": {
      "num": 12
      },
      "obj": {
          "label": "somelabel",
          "order": 1
      },
      "det": {
      "part":"
      }
  </code></pre>