I would like to remove empty string by using toJson from GSON. Example object:
public class ExampleObject {
String defaultEmpty = "";
String example;
public ExampleObject() {
this.example = "foo";
}
and after
using
new Gson().toJson(new ExampleObject());
I am receiving
"defaultEmpty " : "",
"position" : "foo"
Is there any way to not including empty string during deserialization? I know GSON is ignoring null
, but sometimes I have an empty string in my object and I have to ignore it.