diff --git a/UserGuide.md b/UserGuide.md index 2aafb067..49ac54d4 100644 --- a/UserGuide.md +++ b/UserGuide.md @@ -226,6 +226,8 @@ String json = gson.toJson(ints); // ==> json is [1,2,3,4,5] // Deserialization TypeToken> collectionType = new TypeToken>(){}; +// Note: For older Gson versions it is necessary to use `collectionType.getType()` as argument below, +// this is however not type-safe and care must be taken to specify the correct type for the local variable Collection ints2 = gson.fromJson(json, collectionType); // ==> ints2 is same as ints ``` @@ -267,6 +269,8 @@ TypeToken> mapType = new TypeToken>(){}; String json = "{\"key\": \"value\"}"; // Deserialization +// Note: For older Gson versions it is necessary to use `mapType.getType()` as argument below, +// this is however not type-safe and care must be taken to specify the correct type for the local variable Map stringMap = gson.fromJson(json, mapType); // ==> stringMap is {key=value} ```