Skip to content
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

Support naive deserialization of Serializable values as "untyped", same as java.lang.Object #2115

Closed
chrylis opened this issue Aug 18, 2018 · 3 comments
Milestone

Comments

@chrylis
Copy link

chrylis commented Aug 18, 2018

Currently, Jackson is willing to deserialize JSON into a target of type Object as simple Java types--String, Integer, Map, and such. This means that I can successfully deserialize a target property of

Map<String, ? extends Object> miscProperties;

with the results being objects of basic types. So far so good.

However, if I instead I use Serializable as the generic bound, Jackson complains that

Can not construct instance of java.io.Serializable: abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information

While in the case of general type resolution I understand the rationale for what's going on here, in practice every single type that Jackson will produce when faced with a deserialization into Object is Serializable, and it should treat a target of Serializable identically to a target of Object.

I am using 2.8.11.2.

@cowtowncoder
Copy link
Member

Interesting. I'll have to think about this a bit -- I am bit hesitant here since use of Serializable as target type to me does suggest to me possible other interpretation than Object.
But then again, as things are, this case is not supported at all (except if there is custom deserializer registered).

@hubena
Copy link

hubena commented Aug 22, 2018

How to deserialize the generics of the Serializable interface, using Object or using the default deserializer?

@cowtowncoder
Copy link
Member

@hubena I am not sure I fully understand the question.

@chrylis I think I agree with you, in that coercion here makes sense. So I will proceed with the plan.

@cowtowncoder cowtowncoder added this to the 2.10.0 milestone Aug 29, 2018
@cowtowncoder cowtowncoder changed the title Support naive deserialization into Serializable Support naive deserialization of Serializable values as "untyped", same as java.lang.Object Aug 29, 2018
@cowtowncoder cowtowncoder removed the 2.10 label Apr 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants