Open
Description
I have two very simplified model objects here...
class User {
@JsonView({ Views.Detail.class, Views.Summary.class })
String name;
@JsonView({ Views.Detail.class })
Set<Post> posts = new HashSet<>();
}
and
class Post {
@JsonView({ Views.Detail.class, Views.Summary.class })
Date publishDate;
@JsonView({ Views.Detail.class, Views.Summary.class })
String title;
@JsonView({ Views.Detail.class })
Set<Comment> comments = new HashSet<>();
}
I have a JAXRS endpoint annotated with @JsonView
, so serialization is being handled outside of my direct control. I would like to serialize User at the Detail view, but have its collections (in this case, posts) serialize using the Summary view.
I looked at making my own JsonSerializer, but looking at the SerializerProvider, I haven't found a way to change the active view and I'd hate to have to make another view class. Any pointers? Or any other way to think about this?
(ps - where's a good place to post questions like this? I don't really want to clutter the Issues queue unless it requires new code. I posted on StackOverflow but saw nothing there)
Metadata
Metadata
Assignees
Labels
No labels