- Boon 教程
- Boon - 主页
- Boon - 概述
- Boon - 环境设置
- 解析 JSON
- Boon - 转换为对象
- Boon - 转换为映射
- Boon - 源
- 生成 JSON
- Boon - 从对象
- Boon - 从映射
- 日期处理
- Boon - Long 转日期
- Boon - 字符串转日期
- Boon - 生成日期
- 注释
- Boon - @JsonIgnore
- Boon - @JsonInclude
- Boon - @JsonViews
- Boon - @JsonProperty
- Boon 有用资源
- Boon - 快速指南
- Boon - 有用资源
- Boon - 讨论
Boon - @JsonIgnore
@JsonIgnore 用于字段级别,用于标记要忽略的属性或属性列表。
示例 - @JsonIgnore
以下示例适用于 @JsonIgnore −
import org.boon.json.JsonFactory;
import org.boon.json.ObjectMapper;
import org.boon.json.annotations.JsonIgnore;
public class BoonTester {
public static void main(String args[]) {
ObjectMapper mapper = JsonFactory.create();
Student student = new Student(1,11,"1ab","Mark");
String jsonString = mapper.writeValueAsString(student);
System.out.println(jsonString);
}
}
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"}
广告