private static final String JSON = "{\"to_latlnt\" : null, \"phone\" : 77777777777}";
public static class Parsed {
@Key public String to_latlnt;
@Key public Long phone;
@Key public String unspecified;
}
public static void main(String[] args) throws IOException {
JsonFactory factory = new GsonFactory();
Parsed parsed = factory.fromString(JSON, Parsed.class);
System.out.println("parsed JSON: " + factory.toString(parsed));
System.out.println("to_latlnt: " + show(parsed.to_latlnt));
System.out.println("phone: " + show(parsed.phone));
System.out.println("unspecified: " + show(parsed.unspecified));
}
public static String show(Object value) {
if (value == null) {
return null;
}
return Data.isNull(value) ? "JSON null" : value.toString();
}