Boon-jsonignore

提供:Dev Guides
移動先:案内検索

ブーン-@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"}