Category: Java
Convert IP Address to Geo location in Java
We will show you how you can convert IP Address to Geo Location. MaxMind provides a free Geo database and api. We will explain how you can leverage these to lookup the ip address....
JAX-RS JSON Rest Service with Jersey Example
In this tutorial we will show you how you can create a JSON rest service with jersey that will respond with JSON output. This tutorial covers both jersey version 1 and 2. Maven Dependencies...
JAX-RS XML Rest Service with Jersey and JAX-B Example
In this tutorial we will show you how you can create a jersey XML rest service that will respond with XML output. This tutorial covers both jersey version 1 and 2. Maven Dependencies <?xml...
GSON Format Date in JSON object
You can globally specify how to format dates in JSON objects using GSON. Very easy, you will only have to declare your custom date once. GSON Format Date method setDateFormat() witch takes an int...
GSON Excluding fields with modifiers from JSON
By default, if you mark a field as transient, it will be excluded. As well, if a field is marked as “static” then by default it will be excluded. Here is another way you...
Excluding field from JSON with @Expose GSON
GSON provides a way where you can mark certain fields of your objects to be excluded for consideration for serialization and deserialization to JSON. To use this @Expose GSON annotation, you must create Gson...
Custom JSON field naming using GSON
Gson supports custom naming for JSON fields. You can annotate your fields with @SerializedName to provide this functionality. If there is an error in the naming of the field, it’ll throw a Runtime exception....
Deserialise JSON to Java Object using GSON
Gson is a Java library that can be used to convert Java Objects into their JSON representation. It can also be used to convert a JSON string to an equivalent Java object. Gson can...
Serialise Java Object to JSON using GSON
Gson is a Java library that can be used to convert Java Objects into their JSON representation. It can also be used to convert a JSON string to an equivalent Java object. Gson can...