Ignore null fields in model serialization

in Java clients.

Closes #1413
This commit is contained in:
xhh
2015-10-21 12:05:27 +08:00
parent 7f5cdba606
commit 214e0186e8
14 changed files with 31 additions and 87 deletions

View File

@@ -12,12 +12,13 @@ public class JSON {
public JSON() {
mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
mapper.registerModule(new JodaModule());
}
}
/**
* Serialize the given Java object into JSON string.