這是本文件的舊版!
The visibility of the fields
Introduction
本篇文章在說明:
- 預設的輸出欄位顯示規則
- 如何使用@JsonAutoDetect去改變欄位顯示規則
Default Visibility
在沒有特別設定的情況下,Jackson的Serializer是根據Get Method與Class的public data member決定欄位名稱。
public data member:
public String mName = "test";Output:
{"mName":"test"}get method,boolean回傳值被稱為is-getter:
public String getName(){ return "test"; } public boolean isValid(){ return false; }Output:
{"name":"test","valid":false}
Default @JsonAutoDetect
Reference