Category : GSON

Programs work well when dealing with a considerable size of data, but their performance tend to degradate when dealing with large volumes of data. Resources are cheaper than ever, but this does not mean that we can have inefficient programs. Dealing with large amounts of data brings several challenges, even if the task is simple parsing some Java objects into JSON strings, as we will see in this article. Inefficient use of memory can make a program wasting more than 5 times the memory when compared with a more efficient one. This means that one program makes use of 1G of memory, while the inefficient one requires 5G of memory to perform the same task.

Albert Attard
Author: 4 years ago

Java objects can be serialised to JSON strings and deserialised back using JsonSerializer (Article and Java Doc) and the JsonDeserializer (Article and Java Doc) respectively. These two classes simplify the translation between these two realms but add an extra layer which can be avoided. Instead of the JsonSerialiser or JsonDeserialiser we can use an instance of TypeAdapter (Java Doc) which can serialise and deserialise JSON objects efficiently as we will see in this article.

Albert Attard
Author: 4 years ago

GSON provides a set annotations to simplify the serialisation and deserialisation processes. In this article we will see how we can use these annotations and how these can simplify the use of GSON to convert between Java objects and JSON objects.

Albert Attard
Author: 5 years ago

This article continues on a previous article, that described simple and basic use of GSON. In this article we will see how to parse complex JSON objects into existing Java objects that do not necessary have the same structure as the JSON object. We will see how the use of the GSON deserialiser (JsonDeserializer Java Doc) in order to control how the JSON object maps to the Java object.

Albert Attard
Author: 5 years ago