java - Type Information within serialized JSON using GSON -


using jackson have option attach type info serialized object (http://jackson.codehaus.org/1.5.5/javadoc/org/codehaus/jackson/annotate/jsontypeinfo.html).

is there way using gson like:

{     propertyname:"test",     _classname:"foo.bar.testclass" } 

the idea have generic, when arraylist<object> deserialized, right object instances restored it.

i saw question: https://stackoverflow.com/a/8683689/1001027 more or less need works specific class of objects. how implement in such generic way, every object serialized property?

you need implement deserializer, @ type property , cast objects given type. believe, there no other way.

check out javadoc, implementing interface may answer.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -