Cześć wszystkim, jak można deserialize json w Map<String, Property> z Controllera, gdzie Property to Abstract class? Przez cały dzień łapię w mordę ten długi exception
Property
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
property = "propertyType")
@JsonSubTypes({
@JsonSubTypes.Type(value = BooleanProperty.class, name = "boolean"),
@JsonSubTypes.Type(value = DateProperty.class, name = "date"),
@JsonSubTypes.Type(value = TextProperty.class, name = "text"),
@JsonSubTypes.Type(value = NumericalProperty.class, name = "numeric"),
@JsonSubTypes.Type(value = SelectionProperty.class, name = "selection"),
})
@EqualsAndHashCode
@ToString
@Data
public abstract class Property {
@NonNull
public String name = "name";
public String description = "Standard description";
public PropertyFlags flags;
public Property() {
}
public Property(@NonNull String name,
String description,
PropertyFlags flags) {
this.name = name;
this.flags = flags;
this.description = description;
}
DTO
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class AssetPrototypeDTO {
private String id;
private String name;
private String desc;
private Map<String, Property> assetProperties;
private List<Tag> tags;
private String icon;
Exception
Resolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize instance of `java.util.LinkedHashMap<java.lang.String,com.immotef.inspector.commons.property.Property>` out of START_ARRAY token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException:
Cannot deserialize instance of `java.util.LinkedHashMap<java.lang.String,com.immotef.inspector.commons.property.Property>` out of START_ARRAY token
at [Source: (PushbackInputStream); line: 6, column: 7] (through reference chain: com.immotef.inspector.assets.prototypes.AssetPrototypeDTO["assetProperties"])]