Lombok + jackson immutables

After upgrading my project to Spring Boot 1.5.10, Lombok stopped working with Jackson. I mean the immutable creation of DTO when the field names in my objects do not match the fields in the json request:

@Value @Builder public class MyImmutableDto implements Serializable { @JsonProperty("other-field-1-name") private final BigDecimal myField1; @JsonProperty("other-field-2-name") private final String myField2; and a lot of fields there... } 

So, after updating Spring Boot to 1.5.10, this code does not work, and I need to configure lombok as follows:

 lombok.anyConstructor.addConstructorProperties = true 

Does anyone know of any other way to create such objects using jackson + lombok without this lombok fix? Instead of this fix, I can use the following code: @JsonPOJOBuilder and @JsonDeserialize(builder = MyDto.MyDtoBuilder.class) :

 @Value @Builder @JsonDeserialize(builder = MyDto.MyDtoBuilder.class) public class MyDto implements Serializable { // @JsonProperty("other-field-1-name") // not working private final BigDecimal myField1; private final String myField2; private final String myField3; and a lot of fields there... @JsonPOJOBuilder(withPrefix = "") public static final class MyDtoBuilder { } } 

But it does not work with @JsonProperty("other-field-1-name") . Ofc, this can be done with a simple @JsonCreator , but maybe there is some way to use it with lombok using some constructor / jackson annotations?

+8
java immutability jackson spring-boot lombok
source share

No one has answered this question yet.

See related questions:

611
How do I tell Jackson to ignore the field during serialization if its value is zero?
588
Jackson with JSON: unrecognized field not marked as ignorant
576
Ignoring new JSON object fields using Jackson
562
How to use Jackson to deserialize an array of objects
372
Can I use Project Lombok?
341
Create the perfect JPA object
35
What is the equivalent of Jackson @JsonUnwrapped deserialization?
2
Duplicate fields in JSON Response
2
Jackson Private Builders, JDK 9+, Lombok
one
Jackson - Do not use @JsonProperty with @JsonPOJOBuilder or @JsonCreator ctor

All Articles