I'm using jax rs and I want to create responses as json, code:
@Produces(MediaType.APPLICATION_JSON)
public class Rest{
@GET
Path("/Test")
public RestResponse restTest(){
return new RestResponse(100,"ERROR");
}
}
@XmlRootElement()
public class RestResponse{
private Integer code;
private String status;
private Integer id;
public RestResponse(Integer code, String status){
this.code = code;
this.status = status;
}
}
and I'm getting response as :
{"status":"ERROR","code":100,"id":null}
how to remove that "id":null value?
I want response to looks as :
{"status":"ERROR","code":100}
I need it because sometimes id is null and sometimes code is null and I don't want to display it.