– Start
点击此处观看本系列配套视频。
如果一个对象中某个字段中的值是 JSON,输出整个对象会有问题,这时我们可以使用注解 @JsonRawValue
package shangbo.jackson.demo13;
import org.apache.commons.lang3.builder.ToStringBuilder;
import com.fasterxml.jackson.annotation.JsonRawValue;
public class Person {
private String firstname;
private String lastname;
@JsonRawValue
private String address;
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
public String getFirstname() {
return firstname;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
public String getLastname() {
return lastname;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
public String getAddress() {
return address;