Wednesday, 28 October 2015

Jackson Tutorial

In this tutorial series, I am going to explain about Jackson API. Jackson API provides number of methods to work with JSON data. By using Jackson API, you can convert Java object to JSON string and reform the object from JSON string.

Subsequent posts explain you, how to create JSON for a java object. You can create JSON for a Java object in following ways.
a.   Using ObjectMapper
b.   Using JsonNode Tree
c.    Using JSON stream

I am going to use following Maven dependency.
<dependency>
         <groupId>com.fasterxml.jackson.core</groupId>
         <artifactId>jackson-core</artifactId>
         <version>2.6.3</version>
</dependency>

<dependency>
         <groupId>com.fasterxml.jackson.core</groupId>
         <artifactId>jackson-databind</artifactId>
         <version>2.6.3</version>
</dependency>

      Convert object to json using ObjectMapper
      Create JSON Using Tree Mode
      Create JSON Using JsonGenerator
      JsonParser: Parsing JSON data
      Convert JSON to object
      Convert JSON to map
      Pretty print JSON
      Ignore Empty, null fields
      Jackson: Serialize the order of properties
      Jackson: Include only non-null values in json serialization
      Jackson: Change the field names in json serialization
      Jackson: @JsonIgnore: ignore fields while doing json serialization
      Jackson: JsonAnyGetter: Contents of the map are serialized like actual properties of the object
      Jackson: @JsonAnySetter: use this map for any unrecognized fields
      Jackson: Utility class to convert object to json and json to an object
      Jackson: Convert json to an array
      Jackson: Convert json to a list
      Convert HashMap to json string
      DeSerialize private fields
      Custom Serializer
      @JsonSerialize: Custom serialization
      @JsonManagedReference, @JsonBackReference Example
      @JsonDeserialize: Custom deserialization
      How to handle bidirectional relationships?
      JsonView Annotation example
      Parse Json String using JsonNode
      Convert java object to JsonNode
      Convert map to JsonNode
      Convert JsonNode object to Map
      Handling enums
      Define custom Jackson annotation using @JacksonAnnotationsInside
      @JsonAutoDetect: customize visibility semantics for serialization
      Read json from a file and map to an object
      Jackson: Write object json to a file
      Jackson: sort list of objects (JsonNode, ArrayNode)
      Jackson: Use different property names for serialization and deserialization
      Jackson: JsonAlias: use alternative names to a property during deserialization
      Jackson: @JsonValue: Customize the serialized data to be returned
      Jackson: @JsonCreator annotation example
      Inject a value using @JacksonInject during deserialization




Prevoius                                                 Next                                                 Home

No comments:

Post a Comment