-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Implement #5064 (automatic type detection) #5304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 3.x
Are you sure you want to change the base?
Implement #5064 (automatic type detection) #5304
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of (or in addition to), really needs to use POJO type, to ensure type capture works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong location, should be next to other factory methods; I'll move.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)