XStream – Java to XML Using Annotation

Convert Java to XML using annotation In the previous tutorials we saw an example of how to create a java object from XML. That tutorial also explained the concept of aliases and implicit collection. In this tutorial we continue with that but use annotation on the java class. The advantage with annotation is that it … Read more

XStream – Java to XML

The Problem Statement In the previous example we saw how to convert a Java Object to XML and back. In this example we look at another example of Java Object to XML Conversion. The example uses an object called a ‘JazzArtist’. This object has a list of ‘Album’ objects besides some other properties. We see … Read more

XStream – XML To Java

In the earlier tutorial we looked at a way to convertJava to XML and back. In this tutorial we look at some more examples of XML To Java Conversion. XStream can convert XML elements to multiple types depending on the type specified in the Java class. For example a series for similarly named elements can … Read more

XStream – Java to XML and Back

The Problem Statement XStream can be used to convert a Java Object to XML and back. This tutorial aims to create a java representation of the BBC RSS. We will start with a Simple java class and gradually start adding complexity to it so that it can be converted to the BBC RSS. Note that … Read more

Xstream – Introduction

What is XStream XStream is a java library to convert Java Object into XML and back. You can take nearly every arbitrary deeply nested object turn it to XML and read it back without further configuration. You’re done if all you want to have is a persisted object in XML. XStream’s power lies in its … Read more

parse Json for Java – org.json

Parse JSON for Java using org.json org.json has classes to parse Json for Java. It also converts between JSON and XML, HTTP header, Cookies, and CDF. The main classes are: org.json.JSONObject – This class stores unordered key-value pairs. The value can be Boolean, JSONArray, Number, String or JSONObject.NULL. It has constructors to take in a … Read more

Java – Json Simple

Overview of The API Classes Json Simple is, as the name suggest, a very simple API. The API itself is made up of around 13 classes. The main classes are : JSONParser – This parses Json text. It takes in a java.io.Reader or a String Object. It is also possible to pass a ContentHandler or … Read more

Java Google Json (Gson) New in Gson 2.3

What’s new in Gson 2.3 In this article we look at the additions in Google Json 2.3. There are three main changes : @TypeAdapter annotation Support for JsonPath using JsonReader.getPath() New Methods in JsonArray we now present examples for all three @TypeAdapter Annotation TypeAdapters are used to specify rules to convert a java class to … Read more

Java Google Json (Gson) Custom Serializer

Just as we saw in the previous tutorial, Gson provides way to specify custom serializers and deserializers. Register a custom serializer with the GsonBuilder if you need you own way to convert a java object to json and you a custom deserializer if you dont like Gson’s way of converting json to the java object. … Read more