Hi Ahmed,
Unfortunately not in the current version of halbuilder-json, at least - not fully…
com.theoryinpractise.halbuilder.json.JsonRepresentationWriter#getJsonFactory was made a protected method when it was extracted from the core library, and this means you can override it in a subclass and change it to:
protected JsonFactory getJsonFactory() {
JsonFactory f = new JsonFactory();
ObjectMapper om = new ObjectMapper();
om.setSerializationInclusion(Include.NON_NULL);
f.setCodec(om);
f.enable(JsonGenerator.Feature.QUOTE_FIELD_NAMES);
return f;
}
and configure your RepresentationFactory to use your subclass.
rf.withRenderer(HAL_JSON, YourSubClassHere.class);
This will configure Jackson to not include the nulls for any embedded objects, but since the top level properties themselves and handled via a JsonGenerator they won't be covered by this.
I hope to push out some minor releases of some of the sub modules this weekend so I'll take a look at see if I can come up with a good/clean way of filtering the nulls.
In the meantime, I hope this helps.
Mark