I have to migrate the following code from Jackson 1.9 to 2.0
public class ObjectIdDeserializer extends JsonDeserializer<ObjectId> {
@Override
public ObjectId deserialize(JsonParser jp, DeserializationContext context) {
JsonNode oid = jp.readValueAsTree().get("$oid");
return new ObjectId(oid.getTextValue());
}
}
Because the return type of readValueAsTree()
has change from JsonNode
to TreeNode
I'm not able anymore to access to its value. I've tried hasCurrentToken()
, nextToken()
and others strange methods like those without finding a way to access gracefully to the tree nodes. The get
method that I was using rely on a map
, so it does not need any iteration.