Category: Java

java tutorials

How to get Client IP Address using Java

In the following tutorial we will show you how you can get the client IP address using servlet specification. We discuss what you can do if your client is behind a proxy or gateway....
json tutorials

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...
json tutorials

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...
json tutorials

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....
json tutorials

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...
json tutorials

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