You can use a custom type for the json literal. For example, we have this type adapter which handles the serialization concerns:
Then we defined a wrapper type for json literals named JsonBall and registered the above type adapter:
public static class NullHackJsonBallAdapter extends NullHackJsonLiteralAdapter<JsonBall> {
@Override protected JsonBall createJsonLiteralFromRawJson(String json) { return new JsonBall(json); }
}
Unit tests etc which show this:
Hope this helps!
-A
--
You received this message because you are subscribed to the Google Groups "google-gson" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-gson/-/huTzAAOwatYJ.
To post to this group, send email to googl...@googlegroups.com.
To unsubscribe from this group, send email to google-gson...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-gson?hl=en.
You should be able to use a TypeAdapter or JsonSerializer/JsonDeserializer to do this. Seems fairly straightforward.
Indeed! Particularly where patching a class in gson namespace isn't classified as 'ugly hack' :)
-A
To view this discussion on the web visit https://groups.google.com/d/msg/google-gson/-/BEfD6kpBFBYJ.
Amen to that!
To view this discussion on the web visit https://groups.google.com/d/msg/google-gson/-/Q62O2kK36VoJ.