-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
Jackson 2.6: message converter should use type also for Iterable [SPR-13523] #18100
Comments
Sébastien Deleuze commented This question makes perfectly sense, but here I think we have to align with Jackson 2.6 behavior (see this commit), so we have to use exactly the same condition than them to enable this functionality, or that will not work as expected. I think my proposal would be to ask on Jackson side first if they can support that for all iterables. Any thoughts? |
Michael Schoene commented Jackson 2.6.1 has support for Iterable. Using the following code final Iterable<ComProfile> iter = getIterable();
final JavaType javaType = objectMapper.getTypeFactory().constructType( new ParameterizedType()
{
public Type getRawType() { return Iterable.class; }
public Type getOwnerType() { return null; }
public Type[] getActualTypeArguments() { return new Type[] { ComProfile.class }; }
});
System.out.println( objectMapper.writerFor( javaType ).writeValueAsString( iter ) ); I get type info in the json output. Jackson uses a IterableSerializer for this case. And this serializer does support type info (IterableSerializer:106): if (typeSer == null) {
currSerializer.serialize(elem, jgen, provider);
} else {
currSerializer.serializeWithType(elem, jgen, provider, typeSer);
} |
Sébastien Deleuze commented Thanks for your feedback. I have tried to reproduce the issue but it seems that even if we don't pass the type information to Did you guess this issue from reading the source code, or did you reproduce it in within a test case/project? |
Sébastien Deleuze commented Hi Michael Schoene, could you please send me your feedback about how to reproduce the issue? |
Michael Schoene opened SPR-13523 and commented
With #17903 you restrict the use of type to collections. Is this really necessary?
It would be nice to have the feature also for Iterable (as in Spring 4.2.0).
Affects: 4.2.1
Issue Links:
The text was updated successfully, but these errors were encountered: