你需要:
JsonSerializerSettings settings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All };string strJson = JsonConvert.SerializeObject(instance, settings);所以JSON看起来像这样:
{ "$type": "System.Collections.Generic.List`1[[MyAssembly.baseClass, MyAssembly]], mscorlib", "$values": [ { "$id": "1", "$type": "MyAssembly.ClassA, MyAssembly", "Email": "me@here.com", }, { "$id": "2", "$type": "MyAssembly.ClassB, MyAssembly", "Email": "me@here.com", } ]}然后您可以反序列化它:
baseClass obj = JsonConvert.DeserializeObject<baseClass>(strJson, settings)
文档:
TypeNameHandling设置



