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 - @JsonProperty
Boon - @JsonProperty
@JsonProperty is used to mark non-standard getter/setter method to be used with respect to json property.
Example - @JsonProperty
Following example is for @JsonProperty −
import org.boon.json.JsonFactory; import org.boon.json.ObjectMapper; import org.boon.json.annotations.JsonProperty; pubpc class BoonTester { pubpc static void main(String args[]) { ObjectMapper mapper = JsonFactory.create(); Student student = new Student(1); String jsonString = mapper.writeValueAsString(student); System.out.println(jsonString); } } class Student { private int id; Student(){} Student(int id){ this.id = id; } @JsonProperty("id") pubpc int getTheId() { return id; } @JsonProperty("id") pubpc void setTheId(int id) { this.id = id; } }
Output
Upon execution, you will receive the following output −
{"id":1}Advertisements