Implement #5064 (automatic type detection)#5304
Implement #5064 (automatic type detection)#5304rohanlopes20 wants to merge 9 commits intoFasterXML:3.xfrom
Conversation
|
i havent followed the discussion, i dont know whether the name is settled yet, and i dont feel strongly about it, but how about 'readAutomatic' instead? it makes it clear that additional magic is happening, 'automatic' is similar to C++ |
@cowtowncoder can you suggest. |
|
I'll have to think about this: I do not think My initial thinking is/was that we would just have a method for resolving type to create Maybe |
Something like this ? @cowtowncoder. Also, are we going to remove method added for readObject? and test |
|
Yes, remove |
…hub.com/rohanlopes20/jackson-databind-auto-detect-class into jackson-data-bind-auto-detect-class-3.x
|
@rohanlopes20 just realized something: trying to make I am not sure how to go about that, then -- I do NOT like either overloading dozens of So not sure how to proceeed. The only thing I can think of is to use this trick on creating EDIT: or maybe it does work? Test would need to use a POJO type, for sure. EDIT/2: test I added shows it fails the way I originally feared: no type info passed since |
| { | ||
| final String JSON = "[1]"; | ||
| JsonParser p = MAPPER.createParser(JSON); | ||
| List<Integer> ob = MAPPER.forAutomaticType() |
There was a problem hiding this comment.
Instead of (or in addition to), really needs to use POJO type, to ensure type capture works.
There was a problem hiding this comment.
... which, alas, proves failure. :-(
| * Factory method for constructing {@link ObjectReader} that will | ||
| * read or update instances automatically | ||
| */ | ||
| public <T> ObjectReader forAutomaticType(T... reified) { |
There was a problem hiding this comment.
Wrong location, should be next to other factory methods; I'll move.
There was a problem hiding this comment.
Also need name to align with readerFor() somehow
EDIT: chose readerForDetectedType()
|
Ok; edited PR to show how things fail with naive approach. Not sure there is a way to fix this. |
It indeed fails :(. Let me check if any other way possible or not. Currently |
Create new PR based on @cowtowncoder comments
#5064 (comment)