Part 4 - Serializing Composed Java Objects with Jackson

Part 4 - Serializing Composed Java Objects with Jackson

Hello!

This is a post from the Jackson Series: Jackson - The Complete Guide in 20 Parts

In the today's post we're going to serialize a Composed Java Object into a JSON using Jackson!

Composed Objects in Java to a JSON

Java is an Object-Oriented Programming Language and one of the most used feature is Object Composition.

How does Jackson handle object composition when it is serializing an Object to JSON?

Let's create 2 classes to represent Frameworks that belongs to a Language:

The Language class could be:

And the Framework class, composed by the Language class could be as follows:

Great! It's time to create the code to serialize a Framework object with Jackson to see the result:

If you run this code, the output will be:

Awesome!

Jackson can serialize a composed object by default! Let's see how to change a few default behaviours in the next posts!

That's it for today folks!

Let's Serialize Getters methods in the next part: Part 5 - Serializing Getter Methods to JSON with Jackson

Follow us to keep up to date! \o/

Alexandre Gama

Alexandre Gama

Hacking Code Founder

Hacking Code Founder and Writer, Passionate Senior Software Engineer and Team Leader at @Elo7, Teacher of several courses at Caelum, Speaker at many conferences and terrible guitar player.
Jackson JSON Serialization - Java Tutorial - Hacking Code

Part 2 - Simple Serialization into JSON with Jackson

It's time to see the first JSON Serialization with Jackson!

Jackson Pretty JSON Serialization - Java Tutorial - Hacking Code

Part 3 - Printing a Pretty JSON with Jackson

Did your JSON is being printed in a ugly way? Let's see a Pretty JSON Serialization with Jackson

Jackson Composed Objects JSON Serialization - Java Tutorial - Hacking Code

Part 4 - Serializing Composed Java Objects with Jackson

What about serialize a Composed Objects in Java with Jackson?

Jackson Getter JSON Deserialization - Java Tutorial - Hacking Code

Part 5 - Serializing Getter Methods to JSON with Jackson

Let's see hows does getter Serialization with Jackson work!

Jackson Field JSON Serialization - Java Tutorial - Hacking Code

Part 6 - Serializing Java Object into JSON using Fields with Jackson

It's time to serialize Fields to JSON using Jackson

Jackson JSON Ordering Serialization - Java Tutorial - Hacking Code

Part 7 - Ordering Properties in JSON with Jackson Serialization

Did you know that you can Order attributes in JSON with Jackson?

Jackson JSON Raw Content Serialization - Java Tutorial - Hacking Code

Part 8 - Serializing the Raw Content in the JSON with Jackson

Jackson allows us to Serialize that Raw Content of the Java Object!

Jackson Custom Value Serializer - Java Tutorial - Hacking Code

Part 9 - JSON Object with a Custom Value with Jackson

You can serialize the entire object with a custom method with Jackson!

Jackson Root JSON Serialization - Java Tutorial - Hacking Code

Part 10 - JSON Object with a Root with Jackson

Root Serialization is really common in the JSON World. Let's see how Jackson does that!

Jackson Custom JSON Serializer - Java Tutorial - Hacking Code

Part 11 - JSON Custom Serializer with Jackson

Custom Serializer with Jackson is really great! Let's see how to use it!

Jackson JSON Map Serialization - Java Tutorial - Hacking Code

Part 12 - Map into JSON Objects with Jackson

Serializing Map in JSON with Jackson is really easy!

Jackson Ignoring JSON Properties - Java Tutorial - Hacking Code

Part 13 - Ignoring Properties in JSON with Jackson

Let's learn how to configure properties to be ignored in the JSON Serialization with Jackson

Jackson Enum JSON Serialization - Java Tutorial - Hacking Code

Part 14 - Enum Objects into a JSON with Jackson

Did you try to Serialize an Enum to JSON? It's pretty easy with Jackson!

Jackson Deserialization - Java Tutorial - Hacking Code

Part 15 - Jackson Deserialization with ObjectMapper

Is it easy to Deserialize a JSON to a Java Object? Let's see how with Jackson!

Jackson Custom JSON Deserialization - Java Tutorial - Hacking Code

Part 16 - Jackson Deserialization with @JsonSetter

Let's see how Custom JSON Deserialization works with Jackson with @JsonSetter

Jackson Injected JSON Deserialization - Java Tutorial - Hacking Code

Part 17 - Jackson Deserialization with @JacksonInject

Did you know that you can have a value being injected in the generated JSON with Jackson?

Jackson Custom JSON Construction - Java Tutorial - Hacking Code

Part 18 - Jackson Deserialization with @JsonCreator

Jackson Deserialization with @JsonCreator allows us to create a custom constructor

Jackson Map JSON Deserialization - Java Tutorial - Hacking Code

Part 19 - Deserializing Map from a JSON with Jackson

Jackson Map JSON Deserialization to Java Objects can be really easy with Jackson

Jackson Custom JSON Deserialization - Java Tutorial - Hacking Code

Part 20 - Jackson Deserialization with @JsonDeserialize

Jackson Custom JSON Deserialization bring to use power to serialize JSON that doesn't mathc with our expectation

0 Comments

Leave a Reply

Share This
Subscribe To Our Newsletter

Subscribe To Our Newsletter

Join our mailing list to receive the latest news and updates from our team.

You have Successfully Subscribed!

%d bloggers like this: