Intro JsonView
Intro JsonView & How to use
這篇簡介JsonView & How to use,因為資料或功能模組定義,
針對同樣的項目(table/item)允許或需要操作的欄位(column/attribute)有所不同。
可以用JsonView來定義需要產出的欄位。
Example:
public class TestJsonView {
public interface TestView {
}
private String userName;
private String passWord;
@JsonView({TestView.class})
public String getUserName() {
return userName;
}
public String getPassWord() {
return passWord;
}
}
String jsonString = JSONUtils.toJsonString(TestJsonViewObj, TestJsonView.TestView.class);
Output: {“userName” : “xxx”}
只列出userName,不會列出passWord