-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@JsonSerialize
with nullUsing
option not working for String
properties
#33
Comments
@dario-frongillo It should just work. If not, it would be great to have a unit test that shows the problem so we can fix it. |
Hi @cowtowncoder , I customized the object mapper in order to use AfterburnerModule @Component
@Primary
public class CustomObjectMapper extends ObjectMapper {
public CustomObjectMapper() {
// if you comment this instruction the NULL field with annotation
//@JsonSerialize(nullsUsing=MyNullSerializer.class)
// are correctly serialized with MyNullSerializer
this.registerModule(new AfterburnerModule());
disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE);
}
} I have a model Person with certain fields with annotation :@JsonSerialize(nullsUsing=MyNullSerializer.class) for i.e @JsonSerialize(nullsUsing=MyNullSerializer.class)
private String c; I have a simple controller to test it with a curl tool as postman @RequestMapping("/greeting")
public ResponseEntity<?> getProva(){
Person a = new Person();
a.setA("x");
a.setB(null);
a.setC(null);
return ResponseEntity.ok(a);
} the controller return c field with null so MyNullSerializer should intercept the serialization but this does not happen.
on my object mapper all it works.. so AfterburnerModule not allow you to use null serializer.. can you kindly check it ? |
Ok I'll try to create stand-alone test (it makes no sense to add Spring Boot dependency for unit tests) and may be able to resolve this. Afterburner should not change behavior in any way here. |
@JsonSerialize
with nullUsing
option not working for String
properties
Thank you for reporting this -- this turned out to specifically affect Fix will be in 2.9.3 but I also back-ported it in 2.8 branch in case |
Hi All,
if i use AfterModule
this.registerModule(new AfterburnerModule());
the following annotation
@JsonSerialize(nullsUsing=CustomSerialize.class)
not work.
How can enable it ? i want to customize null serialization for certain fields.
Thanks
Dario
The text was updated successfully, but these errors were encountered: