我有一个简单的POJO,我是从Wildfly的Jaxrs网络服务返回的
import org.codehaus.jackson.annotate.JsonRawValue;
public class AttributeFieldListDTO {
private Integer attributeFieldListId;
private String name;
private String category;
@JsonRawValue
private String fields;
public Integer getAttributeFieldListId() {
return attributeFieldListId;
}
public void setAttributeFieldListId(Integer attributeFieldListId) {
this.attributeFieldListId = attributeFieldListId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getFields() {
return fields;
}
public void setFields(String fields) {
this.fields = fields;
}
}
然而,我的字段数据被引用并且换行符被转义。我没有在服务器上配置任何东西,因为我认为杰克逊是默认的。
知道为什么序列化不遵守JsonRawValue注释吗?
答案 0 :(得分:2)
这是正确的导入:
import com.fasterxml.jackson.annotation.JsonRawValue;
为了让它编译,我添加了这个依赖:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<scope>provided</scope>
</dependency>