title: HTML in a JSON String in Java
body: <p>I want to save a <strong>Java</strong> class named <code>MyClass</code> into a text file and I want to use <em>JSON</em> to encode the class for file writing purposes instead of implementing the <code>Serializable</code> interface. Moreover, to save the class I want to use the Google's <a href="https://sites.google.com/site/gson" rel="nofollow">Gson</a> library and in particular the <a href="http://google-son.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/stream/JsonWriter.html" rel="nofollow"><code>JsonWriter</code></a> class. The <code>MyClass</code> class is, for instance, defined as follows:</p>
  
  <pre><code>public class MyClass{
   String html;    
   public MyClass(){}
  }
  </code></pre>
  
  <p>As shown in the example above, <code>MyClass</code> has a <code>String</code> field named <code>html</code>, that obviously must contain <em>HTML code</em>. </p>
  
  <p>Can I save the class into a text file by using JSON via the <code>JsonWriter</code> or I should encode or do something similar with the <code>html</code> field (e.g. a call to an <code>URLEncode</code>-like function) before to give it to <code>JsonWriter</code>?</p>