0

I'm having a problem serializing/deserializing a json , the error is as follows:

Failed to evaluate Jackson deserialization for type [[simple type, class com.challenge.model.Sense]]: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot define Creator property "position" as @JsonUnwrapped: combination not yet supported

My version of Jackson is 2.13

My class is as follows:

import com.fasterxml.jackson.annotation.JsonCreator; 
import com.fasterxml.jackson.annotation.JsonProperty; 
import com.fasterxml.jackson.annotation.JsonUnwrapped;

import java.io.Serializable;

public class Sense implements Serializable {

    private static final long serialVersionUID = -4060851020632500627L;
    private final Moves moves;
    private final Position position;

    @JsonCreator
    public Sense(@JsonProperty(value = "position") @JsonUnwrapped Position position,
                   @JsonProperty(value = "moves") Moves moves) {
        this.position = position;
        this.moves = moves;
    }

    public Position getPosition() {
        return position;
    }

    public Moves getMovements() {
        return moves;
    }
}

Any suggestion?

  • Can you update your question and provide `JSON` payload which you want to deserialise? Why do you want to use `@JsonUnwrapped` annotation there? – Michał Ziober Sep 08 '22 at 15:30

0 Answers0