私はjax rsを使用しており、jsonのコードとして応答を作成したい:
@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;
}
}
そして、私は次のような応答を得ています:
{"status":"ERROR","code":100,"id":null}
その値を削除するには"id":null
?私は次のように見えるように応答したい:
{"status":"ERROR","code":100}
idがnullの場合もあれば、コードがnullの場合もあり、表示したくない場合があるため、必要です。