Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.9.6
-
Fix Version/s: 1.9.7
-
Component/s: Deserializer
-
Labels:None
-
Number of attachments :
Description
Given the following classes:
public interface Pet {} public class Dog implements Pet { String name; public String getName() { return name; } public void setName(String name) { this.name = name; } } public class House { private String petType; @JsonTypeInfo( use = Id.NAME, include = As.EXTERNAL_PROPERTY, property = "petType" ) @JsonSubTypes({ @Type(name = "dog", value = Dog.class) }) Pet pet; public String getPetType() { return petType; } public void setPetType(String petType) { this.petType = petType; } public Pet getPet() { return pet; } public void setPet(Pet pet) { this.pet = pet; } }
Deserializing the following JSON object as an instance of the House class:
{
"petType": "dog",
"pet": {
"name": "Pluto"
}
}
throws the following exception:
org.codehaus.jackson.map.JsonMappingException: Missing external type id property 'petType
If the petType property is removed from the House class, the deserialization succeeds.
It seems that a JSON property already mapped to an actual property cannot be used as type ID anymore.
I will have to see what is going on – it would seem reasonable for this to work.