I would like to ask two questions in regard to json strings when handling polymorphism
- I would like to know if there’s a way to include object type info in
json string when using Gson? I need to pass this type info to my .net
asmx web service which then should reconstruct the object of same
type provided. - How to get such info back form asmx web service and what are the keys used by .net to automatically detect this info? For e.g __type but i don’t know if .net uses this when provided or not
There’s an extension for Gson called RuntimeTypeAdapterFactory. It allows you to add type information to your JSON document. Get the source here.