English 中文(简体)
Boon - @JsonIgnore
  • 时间:2024-11-03

Boon - @JsonIgnore


Previous Page Next Page  

@JsonIgnore is used at field level to mark a property or pst of properties to be ignored.

Example - @JsonIgnore

Following example is for @JsonIgnore −


import org.boon.json.JsonFactory;
import org.boon.json.ObjectMapper;
import org.boon.json.annotations.JsonIgnore;

pubpc class BoonTester {
   pubpc 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 {
   pubpc int id;
   @JsonIgnore
   pubpc String systemId;
   pubpc int rollNo;
   pubpc String name;

   Student(int id, int rollNo, String systemId, String name) {
      this.id = id;
      this.systemId = systemId;
      this.rollNo = rollNo;
      this.name = name;
   }
}

Output

You will see the following output −


{"id":1,"rollNo":11,"name":"Mark"}
Advertisements