I want to save a Java class named MyClass into a text file and I want to use JSON to encode the class for file writing purposes instead of implementing the Serializable interface. Moreover, to save the class I want to use the Google's Gson library and in particular the JsonWriter class. The MyClass class is, for instance, defined as follows:
public class MyClass{
String html;
public MyClass(){}
}
As shown in the example above, MyClass has a String field named html, that obviously must contain HTML code.
Can I save the class into a text file by using JSON via the JsonWriter or I should encode or do something similar with the html field (e.g. a call to an URLEncode-like function) before to give it to JsonWriter?