Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

14
  • 8
    StackOverflow exception -- context.serialize(object) calls itself. Don't know how that worked for you. Commented Dec 3, 2013 at 2:27
  • 1
    @Hoten: this works because GSON takes into account both the declared type and actual type when choosing the serialiser. When field has type Animal GSON will prefer the type adapter for Animal interface, if such has been registered, even if actual type is Cat. In the context.serialize(object) call, however, there is no "declared type" to consider, it's just a Cat that is passed, so the type adapter will not be used. Commented Jan 4, 2015 at 21:00
  • 6
    @Ryan is right, context.serailize(object) ends up in infinite loop - how did it work for rest of you guys? Commented Sep 4, 2016 at 21:27
  • 10
    This doesn't seem to work for me. I get com.google.gson.JsonParseException: no 'type' member found in json file. Commented Oct 18, 2017 at 7:39
  • 4
    I am getting this error com.google.gson.JsonParseException: no 'type' member found in what was expected to be an interface wrapper Commented Dec 4, 2019 at 13:34