【发布时间】:2012-11-28 06:33:54
【问题描述】:
必须在 servlet 过滤器中将 Java 对象序列化为 json 字符串以用于 jersey 应用程序。
有以下对象,
@XmlRootElement
@JsonIgnoreProperties({"bar"})
public class Foo{
String a="1";
String b="2";
@JsonIgnore
String bar="3";
};
ObjectMapper om = new ObjectMapper();
om.writeValueAsString(fooObject);
返回,
{
a:"1",
b:"2",
bar:"3" // Inspite of Jsonignore and jsonignoreproperties bar is returned
}
我该如何克服这个问题?
【问题讨论】: