shau-lok / google-gson

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

Make TypeAdapters public #260

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
We have a couple cases where we need to serialize an object as a List.  As a 
result, I'd like to extract the valueSet from a JsonObject and convert it to an 
ArrayList.  However, all default typeadapters are package-only access, which 
means I can't extend nor delegate.

Any chance we can see these converted to public classes? Any reason they're not?

Original issue reported on code.google.com by aaron.st...@gmail.com on 2 Nov 2010 at 6:28

GoogleCodeExporter commented 9 years ago
We didn't want to increase the footprint of our API by doing so. Also, we 
didn't want to commit to the backward compatibility of these type adapters.

Any reason why you can't just copy over the source-code in your own type 
adapter. When you register a type adapter, it overrides any Gson defaults.

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

GoogleCodeExporter commented 9 years ago
I can't only because the builtin type adapters also reference package-only 
visibility classes.  As another example, I have a json response from a web 
service that returns an array if empty, otherwise a map.  I need to check for 
the type before serializing and set the target field to null, otherwise it 
throws an exception.

The builtin MapTypeAdapter, however, depends on package-local TypeInfoMap.  I'm 
worried that a rat's nest is in store for me if I try and move everything out.  
Preferable would be to be able to decorate MapTypeAdapter and call it a day.

Original comment by aaron.st...@gmail.com on 7 Dec 2010 at 7:49