leogong / google-gson

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

Extensibility of existing TypeAdapter and typeAdpaterFactory #500

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Let me first explain the requirement. I want to embed object type information 
inside the JSON string while serializing it so that on deserializing, type 
information should not be passed.

For e.g.

public class Person{
  private String name;
  private String address;
}

JSON string of this object should look like: {#type:"Person", name:"john", 
address:"Chicago"}

I have gone through ReflectiveTypeAdapterFactory which serializes and 
deserializes any object. Now i want to extend that such a way that type 
information can be written/read while serializing/deserializing.

This class is final and there are so many private methods and nested classes 
because of which I am neither able to extend it nor able to use it in 
composition.

I have to duplicate the code in my project to achieve it. Is there any better 
way to do it or should it be changed in a framework to make it extensible?

I am using gson-2.2.2. Please advise on this!

Thanks,
vidhi

Original issue reported on code.google.com by vidhi.th...@gmail.com on 14 Feb 2013 at 11:31