FasterXML/jackson Tips for JSON in Java

Kamer Elciyar
The Startup
Published in
7 min readMar 6, 2020

--

Hello, in this article I will try to lead you to go beyond default Jackson usage in Spring Boot applications. My main resource will be official documentation as always. Source codes and additional references can be found at the end of the article.

Introduction

All my examples will be in a Spring Boot project that has Web and Lombok dependencies. I will not list all features and explain them one by one like a documentation. Instead, I will ask some questions and answer them. I hope you will find your questions! If not so, you can ask me on Twitter or e-mail.

Q1: How to create a Java POJO for any JSON schema?
Q2: How to use different field names in POJO to map JSON?
Q3: How to deserialize nested JSON objects?
Q4: How to create a custom deserializer?
Q5: How to deserialize enum values?

What is Jackson?

This article is not a zero-to-hero-like article. So, I will not start from basics but introduce Jackson with a few words. Because you may have been using Jackson library without knowing you do so. Jackson is the most widely used JSON processing library for Java. It has 3 core modules (jackson-core, jackson-annotations, jackson-databind), third-party modules for different integrations. You may have been using them because spring-boot-starter-web includes these three…

--

--