Jackson Annotations Tutorial
Selected Reading
- Jackson - Discussion
- Jackson - Useful Resources
- Jackson - Quick Guide
- Disable Annotation
- MixIn Annotations
- Custom Annotation
- Jackson - @JsonFilter
- Jackson - @JsonIdentityInfo
- @JsonBackReference
- @JsonManagedReference
- Jackson - @JsonView
- Jackson - @JsonUnwrapped
- Jackson - @JsonFormat
- Jackson - @JsonProperty
- Jackson - @JsonTypeName
- Jackson - @JsonSubTypes
- Jackson - @JsonTypeInfo
- Jackson - @JsonAutoDetect
- Jackson - @JsonInclude
- Jackson - @JsonIgnoreType
- Jackson - @JsonIgnore
- @JsonIgnoreProperties
- @JsonEnumDefaultValue
- Jackson - @JsonDeserialize
- Jackson - @JsonSetter
- Jackson - @JsonAnySetter
- Jackson - @JacksonInject
- Jackson - @JsonCreator
- Jackson - @JsonSerialize
- Jackson - @JsonRootName
- Jackson - @JsonValue
- Jackson - @JsonRawValue
- @JsonPropertyOrder
- Jackson - @JsonGetter
- Jackson - @JsonAnyGetter
- Jackson - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Jackson - @JsonProperty
Jackson Annotations - @JsonProperty
@JsonProperty is used to mark non-standard getter/setter method to be used with respect to json property.
Example - @JsonProperty
import java.io.IOException; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.ObjectMapper; pubpc class JacksonTester { pubpc static void main(String args[]) throws IOException { ObjectMapper mapper = new ObjectMapper(); String json = "{"id" : 1}"; Student student = mapper.readerFor(Student.class).readValue(json); System.out.println(student.getTheId()); } } 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
1Advertisements