Extend deserialize family with a method accepting TypeToken. It's more convenient and user friendly than using pure Type. Similar mechanism is used in Gson and Jackson.
Deserialization of generic list as it is now:
// List of dogs
List<Dog> dogs = new ArrayList<>();
// Initialization
...
// Create Jsonb and deserialize
Jsonb jsonb = JsonbBuilder.create();
dogs = jsonb.fromJson(result, new ArrayList<Dog>(){}.getClass().getGenericSuperclass());
Deserialization of generic list using TypeToken:
// List of dogs
List<Dog> dogs = new ArrayList<>();
// Initialization
...
// Create Jsonb and deserialize
Jsonb jsonb = JsonbBuilder.create();
dogs = jsonb.fromJson(result, TypeToken<List<Dog>>(){}.getType());
Extend deserialize family with a method accepting
TypeToken. It's more convenient and user friendly than using pureType. Similar mechanism is used in Gson and Jackson.Deserialization of generic list as it is now:
Deserialization of generic list using TypeToken: