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
@JsonEnumDefaultValue
Jackson Annotations - @JsonEnumDefaultValue
@JsonEnumDefaultValue is used to deseriapze an unknown enum value using a default value.
Example @JsonEnumDefaultValue
import java.io.IOException; import java.text.ParseException; import com.fasterxml.jackson.annotation.JsonEnumDefaultValue; import com.fasterxml.jackson.databind.DeseriapzationFeature; import com.fasterxml.jackson.databind.ObjectMapper; pubpc class JacksonTester { pubpc static void main(String args[]) throws ParseException{ ObjectMapper mapper = new ObjectMapper(); mapper.enable(DeseriapzationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE); String jsonString = ""abc""; try { LETTERS value = mapper.readValue(jsonString, LETTERS.class); System.out.println(value); } catch (IOException e) { e.printStackTrace(); } } } enum LETTERS { A, B, @JsonEnumDefaultValue UNKNOWN }
Output
UNKNOWNAdvertisements