jackson-serialization-examples

Commonly-used Java JSON serialization examples

Stars
12

Java and JSON - Jackson examples with ObjectMapper

This repository contains the code samples used in the blog post Java and JSON: Jackson Serialization with ObjectMapper. Follow the link to get all the information about the examples.

Contents

The code contains the following examples, all of them in the same JUnit test to you can actually see what's expected as output.

  • Serialization
    • Jackson Serialize String
    • Jackson Serialize String to JSON Object
    • Jackson Serialize a List of String
    • Jackson Serialize a Map of String
    • Jackson Serialize a String Wrapper class
    • Jackson Serialize objects with LocalDate (default)
    • Jackson Serialize objects with LocalDate in ISO format
  • Deserialization
    • Jackson Deserialize List of Strings
    • Jackson Deserialize and Unwrap Strings
    • Jackson Deserialize values using JsonNode
    • Jackson Deserialize to simple Java object
    • Jackson Deserialize to simple Java object with Empty Constructor
    • Jackson Deserialize to simple Java object using Annotations
    • Jackson Deserialize to a different Java class
    • Jackson Deserialize to Java object ignoring unknown fields with Configuration
    • Jackson Deserialize to Java object ignoring unknown fields with Annotation
    • Jackson Deserialize to a Map
    • Jackson Deserialize to a List of Maps
    • Jackson Deserialize to a List of Objects
    • Jackson Deserialize Optional

Visit the blog post at The Practical Developer site.