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

@JsonView doesn't seem to work with Generic Types #804

Closed
dennisa opened this issue May 26, 2015 · 2 comments
Closed

@JsonView doesn't seem to work with Generic Types #804

dennisa opened this issue May 26, 2015 · 2 comments

Comments

@dennisa
Copy link

dennisa commented May 26, 2015

I have a class defined as

@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
property = "type")
@JsonSubTypes({
@JsonSubTypes.Type(value = MyEvent.class, name = "myevent"),
})
public abstract class Event<D>
{
private D data;
...
}

My event is defined as

public class MyEvent extends Event<User>
{

}

And User is defined as

public class User
{
@JsonView({ Views.Meta.class })
private final String username;

private final String first;

private final String last;
}

However, in my JaxRS web service the username is still getting serialized out when inside the MyEvent class, but on its won (standalone User) it excludes the serialization of the username.

I also tried this using OBJECT_MAPPER.writerWithView(Views.Meta.class).writeValueAsString(myEventInstance)

And again, it seems to ignore the @JSONVIEW annotation

@cowtowncoder
Copy link
Member

Ok, first things first. If you can reproduce this outside of JAX-RS, that would be great.
Alternatively, could you include JAX-RS resource end point declaration? Without that it might not be possible to reproduce the issue.

@cowtowncoder
Copy link
Member

Need a reproducible test case, may be reopened with means to reproduce.

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

2 participants