Boon Tutorial
Selected Reading
- Boon - Discussion
- Boon - Useful Resources
- Boon - Quick Guide
- Boon - @JsonProperty
- Boon - @JsonViews
- Boon - @JsonInclude
- Boon - @JsonIgnore
- Boon - Generating Date
- Boon - String To Date
- Boon - Long To Date
- Boon - From Map
- Boon - From Object
- Boon - Sources
- Boon - To Map
- Boon - To Object
- Boon - Environment Setup
- Boon - Overview
- Boon - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Boon - @JsonInclude
Boon - @JsonInclude
@JsonInclude is used to include properties having null/empty or default values. By default Boon ignore such properties during seriapzation/de-seriapzation.
Example - @JsonInclude
Following example is for @JsonInclude −
import org.boon.json.JsonFactory; import org.boon.json.ObjectMapper; import org.boon.json.annotations.JsonInclude; pubpc class BoonTester { pubpc 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 { pubpc int id; @JsonInclude pubpc 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