- Jackson Annotations Tutorial
- Jackson - Home
- Serialization Annotations
- Jackson - @JsonAnyGetter
- Jackson - @JsonGetter
- @JsonPropertyOrder
- Jackson - @JsonRawValue
- Jackson - @JsonValue
- Jackson - @JsonRootName
- Jackson - @JsonSerialize
- Deserialization Annotations
- Jackson - @JsonCreator
- Jackson - @JacksonInject
- Jackson - @JsonAnySetter
- Jackson - @JsonSetter
- Jackson - @JsonDeserialize
- @JsonEnumDefaultValue
- Property Inclusion Annotations
- @JsonIgnoreProperties
- Jackson - @JsonIgnore
- Jackson - @JsonIgnoreType
- Jackson - @JsonInclude
- Jackson - @JsonAutoDetect
- Type Handling Annotations
- Jackson - @JsonTypeInfo
- Jackson - @JsonSubTypes
- Jackson - @JsonTypeName
- General Annotations
- Jackson - @JsonProperty
- Jackson - @JsonFormat
- Jackson - @JsonUnwrapped
- Jackson - @JsonView
- @JsonManagedReference
- @JsonBackReference
- Jackson - @JsonIdentityInfo
- Jackson - @JsonFilter
- Miscellaneous
- Custom Annotation
- MixIn Annotations
- Disable Annotation
- Jackson Annotations Resources
- Jackson - Quick Guide
- Jackson - Useful Resources
- Jackson - Discussion
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; public class JacksonTester { public 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") public int getTheId() { return id; } @JsonProperty("id") public void setTheId(int id) { this.id = id; } }
Output
1
Advertisements
To Continue Learning Please Login
Login with Google