use of io.micronaut.serde.UpdatingDeserializer in project micronaut-serialization by micronaut-projects.
the class JacksonJsonMapper method updateValueFromTree.
@Override
public void updateValueFromTree(Object value, JsonNode tree) throws IOException {
if (tree != null && value != null) {
Argument<Object> type = (Argument<Object>) Argument.of(value.getClass());
Deserializer deserializer = registry.findDeserializer(type).createSpecific(decoderContext, type);
if (deserializer instanceof UpdatingDeserializer) {
try (JsonParser parser = treeCodec.treeAsTokens(tree)) {
parser.setCodec(objectCodecImpl);
if (!parser.hasCurrentToken()) {
parser.nextToken();
}
// for jackson compat we need to support deserializing null, but most deserializers don't support it.
if (parser.currentToken() != JsonToken.VALUE_NULL) {
final Decoder decoder = JacksonDecoder.create(parser, view);
((UpdatingDeserializer<Object>) deserializer).deserializeInto(decoder, decoderContext, type, value);
}
}
}
}
}
Aggregations