discomarathon / google-gson

Automatically exported from code.google.com/p/google-gson
0 stars 0 forks source link

Custom Deserializers fail if the deserializer context is used on the source JsonElement #44

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Gson gets caught in infinite recursion if a client attempts to convert a
JSON string into a Java object of type Foo with the following
JsonDeserializer registered:

public static class FooTypeAdapter implements JsonDeserializer<Foo> {
  public Foo deserialize(JsonElement json, Type typeOfT,
JsonDeserializationContext context)
      throws JsonParseException {
    Foo fooObj = context.deserialize(json, typeOfT);
    fooObj.setExtraField("ThisIsExtra");
    return fooObj;
  }
}

Original issue reported on code.google.com by joel.leitch@gmail.com on 14 Sep 2008 at 7:58

GoogleCodeExporter commented 9 years ago
See the discussion at:
http://groups.google.com/group/google-gson/browse_thread/thread/196bc3a2798a3905
/5775ce74143d0194#5775ce74143d0194

Original comment by joel.leitch@gmail.com on 14 Sep 2008 at 8:09

GoogleCodeExporter commented 9 years ago
And this discussion: 
http://groups.google.com/group/google-gson/browse_thread/thread/a87d5d47b83d0cbe
Apologies for any excessive notification emails, I accidentally commented on 43 
(serializers) when I really 
intended to comment on 44 (deserializers)

Original comment by mbur...@gmail.com on 17 Jul 2009 at 5:15

GoogleCodeExporter commented 9 years ago
deferred to a future release.

Original comment by inder123 on 29 Sep 2009 at 9:10

GoogleCodeExporter commented 9 years ago
Gosh, this sure would be nice to have.  It would simplify writing custom 
deserializers 
immensely.

Original comment by mbur...@gmail.com on 29 Sep 2009 at 9:26

GoogleCodeExporter commented 9 years ago

Original comment by inder123 on 3 Nov 2010 at 12:01

GoogleCodeExporter commented 9 years ago
I would think that a context.defaultReadObject() similar to the java object 
input stream makes a lot of sense.

Original comment by swall...@gmail.com on 21 Jan 2011 at 4:59

GoogleCodeExporter commented 9 years ago

Original comment by limpbizkit on 29 Dec 2011 at 5:50