Use DeserializationContext.readTreeAsValue() instead of ObjectCodec.treeToValue()

Apache 2.0

In Jackson 3, ObjectCodec is replaced by ObjectReadContext, which does not expose treeToValue. The equivalent method is readTreeAsValue(JsonNode, Class) on DeserializationContext. This recipe rewrites parser.getCodec().treeToValue(node, Foo.class) to ctxt.readTreeAsValue(node, Foo.class) inside methods that have a DeserializationContext parameter (typically JsonDeserializer.deserialize).

org.openrewrite.java.jackson.UseReadTreeAsValueInDeserializer
mod run . --recipe=org.openrewrite.java.jackson.UseReadTreeAsValueInDeserializer

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.