-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Milestone
Description
When I set the ObjectMapper MapperConfig to not AutoDetect and use the BasicClassIntrospector to get the properties, I seem to still be getting the Methods. I am currently using version 2.7.3.
The following code produces this output:
Found property count 2, there should only be one??
Found property: name=name, internalName=name
Found property: name=groupname, internalName=groupname
I think it should produce only this output:
Found property: name=groupname, internalName=groupname
public static void main(String [] args) {
class TCls {
@JsonProperty("groupname")
private String groupname;
public void setName(String str) {
this.groupname = str;
}
public String getName() {
return groupname;
}
}
ObjectMapper om = new ObjectMapper();
// Only use explicitly specified values to be serialized/deserialized (i.e., JSONProperty).
om.configure(com.fasterxml.jackson.databind.MapperFeature.AUTO_DETECT_FIELDS, false);
om.configure(com.fasterxml.jackson.databind.MapperFeature.AUTO_DETECT_GETTERS, false);
om.configure(com.fasterxml.jackson.databind.MapperFeature.AUTO_DETECT_SETTERS, false);
om.configure(com.fasterxml.jackson.databind.MapperFeature.AUTO_DETECT_IS_GETTERS, false);
om.configure(com.fasterxml.jackson.databind.MapperFeature.USE_GETTERS_AS_SETTERS, false);
om.configure(com.fasterxml.jackson.databind.MapperFeature.CAN_OVERRIDE_ACCESS_MODIFIERS, true);
om.configure(com.fasterxml.jackson.databind.MapperFeature.INFER_PROPERTY_MUTATORS, false);
om.configure(com.fasterxml.jackson.databind.MapperFeature.USE_ANNOTATIONS, true);
JavaType javaType = om.getTypeFactory().constructType(TCls.class);
BasicClassIntrospector introspector = new BasicClassIntrospector();
BasicBeanDescription bdesc = introspector.forSerialization(om.getSerializationConfig(), javaType, null);
List<BeanPropertyDefinition> bprops = bdesc.findProperties();
if (1 != bprops.size()) {
System.out.println("Found property count " + bprops.size() + ", there should only be one??");
}
bprops.forEach(prop -> {
System.out.println("Found property: name=" + prop.getName() + ", internalName=" + prop.getInternalName());
});
}
Metadata
Metadata
Assignees
Labels
No labels