jackson-databind
jackson-databind copied to clipboard
Autodetect classes in ObjectMapper
https://github.com/FasterXML/jackson-databind/issues/5064
I'm not a fan of this change. It is a hack to work around language limitations. It makes all sorts of invalid readValue calls compile (e.g. nonsense like mapper.readValue("\"foo\"", "java.lang.String")), leading to confusing compile or runtime errors. It also breaks in more complex scenarios with generic parameters, e.g. <T> T myReadMethod(InputStream stream) { return mapper.readValue(stream); } or when deserializing parameterized types. In my opinion, this makes the API more complex and does not justify saving a few characters to specify the type.
@yawkat has valid point. And also ObjectWriter/ObjectReader in mind, we shod be careful to not add up big complexity or API inconsistency.
@yawkat 's point make sense. Let me know if we can ignore this or need more discussion. @JooHyukKim @cowtowncoder
@cowtowncoder can you check above.
@rohanlopes20 I think I'll need to postpone this a bit, consider post 2.19.0. I think it does require more discussion. I like the idea, but I think @yawkat's concerns are valid.
We could, for example, consider alternate method name instead of overload. Like, maybe
ObjectMapper.read(InputStream)