Is it possible to use default serializer during custom serializer?

47 views
Skip to first unread message

Dave

unread,
Oct 9, 2009, 5:40:50 PM10/9/09
to google-gson
I've started to use gson a bit and I ran into a situation where I want
to have a custom serializer that does something with a property on the
object, and then just calls the default serializer for the object
being serialized...is that possible?

I realize that I could serialize the class myself, but I would rather
let the default Gson serializer do it so that I don't have to adjust
the code as new properties are added to the class.

I tried calling serialize on the JsonSerializationContext, but that of
course caused an infinite loop. I then tried to use a different Gson
instance, but the toJson() methods return String not JsonElement.

Any tips?

Joel

unread,
Oct 9, 2009, 8:28:41 PM10/9/09
to google-gson
This is being tracked in Issue 43 (http://code.google.com/p/google-
gson/issues/detail?id=43). As well, the equivalent feature for
deserialization is being tracked in Issue 44 (http://code.google.com/p/
google-gson/issues/detail?id=44).

We just released version 1.4 BETA, but we believe we can fix these
bugs without an API change; therefore, we will be targetting this with
the full 1.4 release.
Reply all
Reply to author
Forward
0 new messages