- 傑克遜註釋教程
- 傑克遜 - 主頁
- 序列化註釋
- 傑克遜 - @JsonAnyGetter
- 傑克遜 - @JsonGetter
- @JsonPropertyOrder
- 傑克遜 - @JsonRawValue
- 傑克遜 - @JsonValue
- 傑克遜 - @JsonRootName
- 傑克遜 - @JsonSerialize
- 反序列化註釋
- 傑克遜 - @JsonCreator
- 傑克遜 - @JacksonInject
- 傑克遜 - @JsonAnySetter
- 傑克遜 - @JsonSetter
- 傑克遜 - @JsonDeserialize
- @JsonEnumDefaultValue
- 屬性包含註釋
- @JsonIgnoreProperties
- 傑克遜 - @JsonIgnore
- 傑克遜 - @JsonIgnoreType
- 傑克遜 - @JsonInclude
- 傑克遜 - @JsonAutoDetect
- 型別處理註釋
- 傑克遜 - @JsonTypeInfo
- 傑克遜 - @JsonSubTypes
- 傑克遜 - @JsonTypeName
- 通用註釋
- 傑克遜 - @JsonProperty
- 傑克遜 - @JsonFormat
- 傑克遜 - @JsonUnwrapped
- 傑克遜 - @JsonView
- @JsonManagedReference
- @JsonBackReference
- 傑克遜 - @JsonIdentityInfo
- 傑克遜 - @JsonFilter
- 其他
- 自定義註釋
- MixIn 註釋
- 停用註釋
- 傑克遜註釋資源
- 傑克遜 - 快速指南
- 傑克遜 - 有用資源
- 傑克遜 - 討論
傑克遜註釋 - @JsonIgnore
@JsonIgnore 在欄位級別用於將要忽略的屬性或屬性列表標記出來。
示例 - @JsonIgnore
import java.io.IOException;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.ObjectMapper;
public class JacksonTester {
public static void main(String args[]){
ObjectMapper mapper = new ObjectMapper();
try{
Student student = new Student(1,11,"1ab","Mark");
String jsonString = mapper
.writerWithDefaultPrettyPrinter()
.writeValueAsString(student);
System.out.println(jsonString);
}
catch (IOException e) {
e.printStackTrace();
}
}
}
class Student {
public int id;
@JsonIgnore
public String systemId;
public int rollNo;
public String name;
Student(int id, int rollNo, String systemId, String name){
this.id = id;
this.systemId = systemId;
this.rollNo = rollNo;
this.name = name;
}
}
輸出
{
"id" : 1,
"rollNo" : 11,
"name" : "Mark"
}
廣告