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 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

Java JSON Jackson Introduction

Overview of the Java JSON Jackson library The java JSON Jackson is a JSON library for Java It has very powerful data binding capabilities and provides a framework to serialize custom java objects to JSON  and deserialize JSON  back to Java objects. JSON written with Jackson can contain embedded class information that helps in creating the … Read more

Java 8 – Streams

Introduction In the first article we learned about Lambdas, functional interfaces and method references introduced in Java 8. In the previous article we saw some of the new methods added in the Collections hierarchy. In this article we look at what is probably the most important addition to Java since generics – Streams. Streams make … Read more

Java IO – Pipes And Print Writer Next

Read from Console using pipes We see the use of a buffered reader and writer and a piped reader and writer. The example also demonstrates how to read from a console continuously. The example reads from a console using a buffered reader, passes the characters to a piped writer. A piped reader reads the characters … Read more