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 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 […]

Java Gson – parsing json to java token by token

Converting json to a java object In the earlier tutorials we saw how to convert json to a java object. In This tutorial we see how to parse json and obtain individual tokens. Although this may seem like a cumbersome way to build java object from json, however it is extremely powerful and may be […]

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 class. Create a new instance of this class and use the method

classOfT is the java […]

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 […]

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 […]

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 […]

Java Jackson – Json annotations and dyna beans

Also see json simple org.json The json string at times have a lot of properties. It seems a waste creating a POJO with all those properties. Wouldnt it be great if there was a catch’all that could read all properties in a map? Jackson provides annotations to do just that. In the example below we […]

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 […]

Ignore fields in JSON using Jackson @JsonIgnoreProperties or @JsonIgnore

Jackson provides an efficient way to bind JSON to POJOs. However, at times, certain properties may need to be ignored while converting a JSON to Java Object or Java Object to JSON. Jackson provides three ways to Ignore fields in JSON. @JsonIgnoreProperties– This annotation can be used at the type level to ignore json properties. […]

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 […]

Scroll to top