From 0409a2ecab8026848ec34dbd0f09378484d9d840 Mon Sep 17 00:00:00 2001 From: Prempal Singh Date: Wed, 18 Sep 2019 23:09:14 +0530 Subject: [PATCH] Fix typo in UserGuide (#1572) --- UserGuide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UserGuide.md b/UserGuide.md index f5d2fff0..40e73afe 100644 --- a/UserGuide.md +++ b/UserGuide.md @@ -248,7 +248,7 @@ gson.toJson(foo); // May not serialize foo.value correctly gson.fromJson(json, foo.getClass()); // Fails to deserialize foo.value as Bar ``` -The above code fails to interpret value as type Bar because Gson invokes `list.getClass()` to get its class information, but this method returns a raw class, `Foo.class`. This means that Gson has no way of knowing that this is an object of type `Foo`, and not just plain `Foo`. +The above code fails to interpret value as type Bar because Gson invokes `foo.getClass()` to get its class information, but this method returns a raw class, `Foo.class`. This means that Gson has no way of knowing that this is an object of type `Foo`, and not just plain `Foo`. You can solve this problem by specifying the correct parameterized type for your generic type. You can do this by using the [`TypeToken`](https://static.javadoc.io/com.google.code.gson/gson/2.8.5/com/google/gson/reflect/TypeToken.html) class.