Jackson serialize/deserialize private builder

Viewed 11

I'm trying to serialize/deserialize the DynamoDB Record class using Jackson.

I have no control over this class, so I tried to use Jackson mixins.

I did the following:

@JsonDeserialize( builder = RecordBuilderMixIn.class )
private abstract static class RecordMixIn
{
}

@JsonPOJOBuilder( withPrefix = "" )
private abstract class RecordBuilderMixIn
{
}

var mapper = new ObjectMapper()
                .addMixIn( Record.Builder.class, RecordBuilderMixIn.class )
                .addMixIn( Record.class, RecordMixIn.class );

But I get the following error when I do mapper.readValue(json, Record.class);:

com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Builder class `com.surecloud.jackson.RecordObjectMapper$RecordBuilderMixIn` does not have build method (name: 'build')

Any ideas on how to solve this?

Thanks

0 Answers
Related