- Boon - Home
- Boon - Overview
- Boon - Environment Setup
- Parsing JSON
- Boon - To Object
- Boon - To Map
- Boon - Sources
- Generating JSON
- Boon - From Object
- Boon - From Map
- Date Handling
- Boon - Long To Date
- Boon - String To Date
- Boon - Generating Date
- Annotations
- Boon - @JsonIgnore
- Boon - @JsonInclude
- Boon - @JsonViews
- Boon - @JsonProperty
- Boon Useful Resources
- Boon - Quick Guide
- Boon - Useful Resources
- Boon - Discussion
Boon - @JsonInclude
@JsonInclude is used to include properties having null/empty or default values. By default Boon ignore such properties during serialization/de-serialization.
Example - @JsonInclude
Following example is for @JsonInclude −
import org.boon.json.JsonFactory;
import org.boon.json.ObjectMapper;
import org.boon.json.annotations.JsonInclude;
public class BoonTester {
public static void main(String args[]) {
ObjectMapper mapper = JsonFactory.createUseAnnotations( true );
Student student = new Student(1,null);
String jsonString = mapper.writeValueAsString(student);
System.out.println(jsonString);
}
}
class Student {
public int id;
@JsonInclude
public String name;
Student(int id, String name) {
this.id = id;
this.name = name;
}
}
Output
When the script runs successfully, you will see the following output −
{"id":1,"name":null}
Advertisements