I have the following listing declaration:
@Document
@JsonFormat(shape= JsonFormat.Shape.OBJECT)
@JsonAutoDetect()
public enum Compass {
north("Upper Center"),
south("Lower Center"),
east("Left Center"),
west("Right Center"),
ne("Upper Right"),
nw("Upper Left"),
se("Lower Right"),
sw("Lower Left"),
;
@JsonProperty
private String presentableName;
@JsonProperty
private String name;
private Compass() {}
private Compass(String presentableName) {
this.presentableName = presentableName;
}
public String getPresentableName() {
return presentableName;
}
public void setPresentableName(String presentableName) {
this.presentableName = presentableName;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@JsonCreator
public static Compass fromObject(@JsonProperty("name") String name, @JsonProperty("presentableName") String presentableName) {
return Compass.sw;
}
}
The input comes as a json object, and most of it is deserialized correctly, but the corresponding part has the following form, where placement- Compass:
{"placement":{"name":"se","presentableName":"Lower Right"}}
Decontamination does not work. I thought it JsonCreatorwould work here, but for some reason I get
org.springframework.web.HttpMediaTypeNotSupportedException: content type 'application / json; charset = UTF-8 'is not supported
which is really just a symptom of deserialization failure.
If I changed the creator to:
@JsonCreator
public static Compass fromObject(@JsonProperty("name") String name) {
return Compass.sw;
}
, { se ( json, , , , , )
jackson 2.2.3, .