– Start
点击此处观看本系列配套视频。
如果 JSON 和对象字段名不匹配,我们可以使用注解 @JsonGetter 和 @JsonSetter
package shangbo.jackson.demo11;
import java.util.Date;
import org.apache.commons.lang3.builder.ToStringBuilder;
import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonSetter;
public class Person {
private String firstname;
private String lastname;
private Date birthday;
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;
}
@