Skip to content

Commit

Permalink
Add check for ALLOW_CASE_INSENSITIVE_PROPERTIES feature FasterXML#1983
Browse files Browse the repository at this point in the history
  • Loading branch information
alevskyi committed Feb 7, 2020
1 parent d9e52c3 commit a55f0a9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,12 @@ public Object deserializeTypedFromObject(JsonParser p, DeserializationContext ct
// Ok, let's try to find the property. But first, need token buffer...
TokenBuffer tb = null;

boolean ignoreCase = ctxt.isEnabled(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES);
for (; t == JsonToken.FIELD_NAME; t = p.nextToken()) {
String name = p.getCurrentName();
if (ignoreCase) {
name = name.toLowerCase();
}
p.nextToken(); // to point to the value
if (name.equals(_typePropertyName)) { // gotcha!
return _deserializeTypedForId(p, ctxt, tb);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.fasterxml.jackson.databind.BeanDescription;
import com.fasterxml.jackson.databind.DatabindContext;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.cfg.MapperConfig;
import com.fasterxml.jackson.databind.jsontype.NamedType;

Expand Down Expand Up @@ -138,6 +139,9 @@ public JavaType typeFromId(DatabindContext context, String id) {
}

protected JavaType _typeFromId(String id) {
if(_config.isEnabled(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES)) {
id = id.toLowerCase();
}
// Now: if no type is found, should we try to locate it by
// some other means? (specifically, if in same package as base type,
// could just try Class.forName)
Expand Down

0 comments on commit a55f0a9

Please sign in to comment.