Jackson を使用して、Tomcat/jersey で Java オブジェクトを JSON オブジェクトに変換しようとしています。また、特定のプロパティのシリアル化 (書き込み) を動的に抑制したい。
JsonIgnore を使用できますが、実行時に無視の決定を下したいと考えています。何か案は??
以下の例のように、User オブジェクトを JSON にシリアル化するときに「id」フィールドを抑制したいと考えています。
new ObjectMapper.writeValueAsString(user);
class User {
private String id = null;
private String firstName = null;
private String lastName = null;
//getters
//setters
}//end class