Scenario
- Jersey/JacksonJson for my RESTful web services requests.
- An entity A that has properties X,Y,Z.
- 2 RESTful requests.
- Request 1 should return entity A with properties X,Y in the JSON response
- Request 2 should return entity A with properties X,Y,Z in the JSON response
- Entity A is configured such that property Z is using @JsonIgnore so it is not returned in the JSON response
Problem
How do I return property Z in Request 2 if it is set to @JsonIgnore in the entity? Is there are better way to do this dynamically besides using @JsonIgnore? Below is some "Demonstration" code to help clarify my question.
@Entity
Class A implements Serializable {
String X;
String Y;
String Z;
@JsonIgnore
public String getZ() {
return Z;
}
}
@Path("form")
Class Request {
@GET
@Path("request1")
@Produces({"application/json"})
public A request1() {
return A;
}
@GET
@Path("request2")
@Produces({"application/json"})
public A request2() {
return A;
}
}