Resolve element type from NodeType before falling back to reflection when reading values from JsonNode.
This commit changes the node value retrieval so that it first tries to determine the node type before falling back to reflective access of the _value field. Closes #2838 Original pull request: #2842
This commit is contained in:
committed by
Mark Paluch
parent
2f34f63e28
commit
7fad17a1de
@@ -436,8 +436,20 @@ public class Jackson2HashMapper implements HashMapper<Object, String, Object> {
|
||||
} else if (element.isContainerNode()) {
|
||||
doFlatten(propertyPrefix, element.fields(), resultMap);
|
||||
} else {
|
||||
resultMap.put(propertyPrefix, new DirectFieldAccessFallbackBeanWrapper(element)
|
||||
.getPropertyValue("_value"));
|
||||
|
||||
switch (element.getNodeType()) {
|
||||
case STRING -> resultMap.put(propertyPrefix, element.textValue());
|
||||
case NUMBER -> resultMap.put(propertyPrefix, element.numberValue());
|
||||
case BOOLEAN -> resultMap.put(propertyPrefix, element.booleanValue());
|
||||
case BINARY -> {
|
||||
try {
|
||||
resultMap.put(propertyPrefix, element.binaryValue());
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
default -> resultMap.put(propertyPrefix, new DirectFieldAccessFallbackBeanWrapper(element).getPropertyValue("_value"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user