Boon 简明教程
Boon - @JsonProperty
@JsonProperty 用于将非标准的 getter/setter 方法标记为与 json 属性一起使用。
Example - @JsonProperty
以下是有关 @JsonProperty 的示例:
import org.boon.json.JsonFactory;
import org.boon.json.ObjectMapper;
import org.boon.json.annotations.JsonProperty;
public class BoonTester {
public static void main(String args[]) {
ObjectMapper mapper = JsonFactory.create();
Student student = new Student(1);
String jsonString = mapper.writeValueAsString(student);
System.out.println(jsonString);
}
}
class Student {
private int id;
Student(){}
Student(int id){
this.id = id;
}
@JsonProperty("id")
public int getTheId() {
return id;
}
@JsonProperty("id")
public void setTheId(int id) {
this.id = id;
}
}