Category: Java

jersey tutorials

JAX-RS @PathParam Example

The JAX-RS @PathParam annotation allows you to inject the value of named URI path parameters that were defined in the @Path annotation expression. In this example we’ll explore the different ways you can use...
jersey tutorials

JAX-RS @QueryParam Example

The JAX-RS @QueryParam annotation allows you to inject URI query parameters into your Java parameters. These query parameters are represented as a string of characters within the HTTP request. JAX-RS can convert this string...
json tutorials

Serializing and Deserializing Enums using GSON

By default Gson serializes enums by name in lowercase. If this is not sufficient and you want some other stirng or an integer value, then have a look at the @SerializedName annotation. Gson can...
json tutorials

Gson Streaming API Mixing With Object Model

In the previous example we talked about the core GSON Streaming API. This example we’ll mix GSON Streaming API together with GSON Object Model. This leaves us with the benefit of not loading the...
json tutorials

GSON Streaming API Reading and Writing Example

Gson Streaming API is used to process large JSON objects and is available via the JsonReader and JsonWriter classes. This streaming approach is very useful in situations where it is not desirable to load...
json tutorials

GSON Custom Serialization And Deserialization

GSON Custom serialization and deserialization is often necessary when working with library classes like date and time. Gson allows you to register your own custom serializers and deserializers. The following example will show you...
json tutorials

GSON Serializing and Deserializing Generic Types

This example shows how to serialize and deserialize a generic class using GSON. Generic type information is lost while serializing because of Java Type Erasure. You can solve this problem by specifying the correct...
json tutorials

GSON Serialize and Deserialize Collections Example

GSON can serialize and Deserialize collections. In this example we serialize a collection of Integer into JSON representation and using the TypeToken to deserialize the collection of Integers into the arbitrary Java Object. Serialize...
json tutorials

GSON Array and Multi Dimensional Array Example

Arrays are a very basic structure and can be serialized or deserialized using GSON API. Here we show you how to serialize and deserialize and array or a multi dimensional array to and from...