Java Gson – Convert json to a java object tree

Converting json to a java object In the Earlier tutorial we saw how to convert json to a java object. In this tutorial, we build a tree of com.google.gson.JsonElement from the json string. The tree can then be traversed to build java objects. JsonElement has methods such as isJsonObject(), isJsonNull(), etc that can be used … Read more

Java Gson – Convert JSON string to a java object

Google json provides methods to convert a JSON string to a Java object. Gson uses the name to match the json property to the java field. There are two ways to convert json to java. Using the com.google.gson.Gson class. Create a new instance of this class and use the method public <T> T fromJson(String json, … Read more

Java Google Json (Gson) Introduction

Overview of The Gson API google json – gson is an open source java api for parsing and building json. It has extensive support for java generics. It also provides support for converting third party classes to json. It can be used to serialize and deserialize complex objects with deep hierarchies that may contain generic … Read more

Java json – jackson Mix- In Annotations

Also see json simple org.json Annotations are a great way to manage serialization and deserialization in Jackson. However, what do you do if you want to annotate a third party class, or if you dont want to tightly couple your POJOs to jackson annotations. This is where Mix-in comes into play. You define a mix-in … Read more

Java json – jackson List serialization

Also see json simple org.json In this tutorial we will see how to convert a java List to JSON. Serializing list is a little tricky since by default the type info is not stored while serializing and deserializing lists. In this tutorial we look at two examples. In the first example we serialize an Object … Read more

Java Jackson – Json Polymorphism

Also see json simple org.json Jackson provides a way to maintain sub type information while serializing java objects. It is possible to recreate the exact sub type. The type information can be embedded into the json as a property. In the example below we create a zoo, that has a list of animals. The animal … Read more

Jackson- Json Java Data Binding

What is JSON Java Data Binding? A thing that most java developers love to deal with is …. Java POJO. Wouldn’t you love a black box where you can see JSON string entering from one side and POJOs coming out from the other. That’s what Jackson’s JSON java data binding does. This can be best … Read more