eclipse-ee4j / eclipse-ee4j/jersey

JsonView not working

Open
#4,534 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
730
Forks
382
PR merge metrics
No merged PRs in 30d

Description

I try to use @JsonView annotation from Jackson to fitre JAX-RS response as described in 2.29.1 Jersey documentation.
But I always receive full object.
I have declared the JacksonFeature in my own extension of ResourceConfig as follow :
register(JacksonFeature.class);

API ressource :
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Path("vip")
@JsonView(UserView.Min.class)
User getUser();

View Object :

public class UserView {

public static class Min {}

public static class Full extends Min {}
}

DTO object ,
public class User {

@JsonView(UserView.Min.class)
public String firstName;

@JsonView(UserView.Min.class)
public String lastName;

@JsonView(UserView.Full.class)
public String adresse;
.....

There is any known bug ?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.