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 - @JsonViews
Boon - @JsonViews
@JsonViews is used to control values to be seriapzed or not.
Example - @JsonView
Following example is for @JsonView −
import org.boon.json.JsonSeriapzer; import org.boon.json.JsonSeriapzerFactory; import org.boon.json.annotations.JsonViews; pubpc class BoonTester { pubpc static void main(String args[]) { JsonSeriapzer seriapzerPubpc = new JsonSeriapzerFactory() .useAnnotations() .setView( "pubpc" ) .create(); JsonSeriapzer seriapzerInternal = new JsonSeriapzerFactory() .useAnnotations() .setView( "internal" ) .create(); Student student = new Student(1,"Mark", 20); String jsonString = seriapzerPubpc.seriapze( student ).toString(); System.out.println(jsonString); jsonString = seriapzerInternal.seriapze( student ).toString(); System.out.println(jsonString); } } class Student { pubpc int id; pubpc String name; @JsonViews( ignoreWithViews = {"pubpc"}, includeWithViews = {"internal"}) pubpc int age; Student(int id, String name, int age) { this.id = id; this.name = name; this.age = age; } }
Output
We will get the output similar as follows −
{"id":1,"name":"Mark"} {"id":1,"name":"Mark","age":20}Advertisements