Disable DeserializationFeature.FAIL_ON_NULL_CREATOR_PROPERTIES for an endpoint

31 Views Asked by At

I am adding an endpoint to an app, which receives a json and in spring this is automatically converted to a DTO I created. Many fields can be null, which I set in Kotlin with question mark and it is not a problem when the value is missing in the json, but the problem is when there is explictly "null".

JSON parse error: Null value for creator property 'trial_period' (index 6); DeserializationFeature.FAIL_ON_NULL_CREATOR_PROPERTIES enabled"

It has been set for some reason in application.yml

jackson:
 deserialization:
  fail-on-null-creator-properties: true

so I do not want to change it globally, but I need to disable it for this endpoint. How can I do it?

Thank you.

1

There are 1 best solutions below

1
Francisco Valadares On

One option is put anotation in your DTO.

@JsonInclude(JsonInclude.Include.ALWAYS)
private String trial_period;