This repository contains examples of various Java-to-JSON and JSON-to-Java conversions using the Jackson library. The examples demonstrate how to convert different Java types, such as primitive types, Strings, Dates, Arrays, Collections, Maps, and custom Java objects, to their JSON equivalents, and vice versa.
This project uses the Jackson library for JSON serialization and deserialization. Add the following dependency to your project:
com.fasterxml.jackson.core jackson-databind 2.13.0The examples in this repository are organized into the following Java classes:
- PrimitiveTypesExample.java: Contains examples of converting primitive types and their wrapper classes to JSON and vice versa.
- StringExample.java: Contains examples of converting Strings to JSON and vice versa.
- DateExample.java: Contains examples of converting java.util.Date objects to JSON and vice versa.
- ArrayAndCollectionExample.java: Contains examples of converting Arrays and Collections (such as Lists and Sets) to JSON and vice versa.
- MapExample.java: Contains examples of converting Maps (such as HashMaps) to JSON and vice versa.
- CustomObjectExample.java: Contains examples of converting custom Java objects to JSON and vice versa.
Open to use