我在https://github.com/ayoung/Newtonsoft.Json尝试了 JSON.NET 和 MonoTouch 端口,但得到了这个序列化错误:
Ran out of trampolines of type 2 in '/private/var/mobile/Applications/A901C3E6-D9AB-44AF-AA13-6B6E44467BAE/StaffRostering.app/mscorlib.dll' (128)
Stacktrace:
at Newtonsoft.Json.Serialization.DefaultContractResolver.GetParametrizedConstructor (System.Type) [0x00009] in /Users/vink/Dropbox/Ajilon Source/Apps/Utils/Newtonsoft.Json.MonoTouch/Newtonsoft.Json/Serialization/DefaultContractResolver.cs:336
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateObjectContract (System.Type) [0x000ae] in /Users/vink/Dropbox/Ajilon Source/Apps/Utils/Newtonsoft.Json.MonoTouch/Newtonsoft.Json/Serialization/DefaultContractResolver.cs:310
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract (System.Type) [0x000b0] in /Users/vink/Dropbox/Ajilon Source/Apps/Utils/Newtonsoft.Json.MonoTouch/Newtonsoft.Json/Serialization/DefaultContractResolver.cs:675
at Newtonsoft.Json.Utilities.ThreadSafeStore`2.AddValue (TKey) <0x000bf>
at Newtonsoft.Json.Utilities.ThreadSafeStore`2.Get (TKey) <0x00173>
at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract (System.Type) [0x00011] in /Users/vink/Dropbox/Ajilon Source/Apps/Utils/Newtonsoft.Json.MonoTouch/Newtonsoft.Json/Serialization/DefaultContractResolver.cs:196
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.GetContractSafe (object) [0x00008] in /Users/vink/Dropbox/Ajilon Source/Apps/Utils/Newtonsoft.Json.MonoTouch/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs:86
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize (Newtonsoft.Json.JsonWriter,object) [0x00011] in /Users/vink/Dropbox/Ajilon Source/Apps/Utils/Newtonsoft.Json.MonoTouch/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs:70
at Newtonsoft.Json.JsonSerializer.SerializeInternal (Newtonsoft.Json.JsonWriter,object) [0x00012] in /Users/vink/Dropbox/Ajilon Source/Apps/Utils/Newtonsoft.Json.MonoTouch/Newtonsoft.Json/JsonSerializer.cs:451
at Newtonsoft.Json.JsonSerializer.Serialize (Newtonsoft.Json.JsonWriter,object) [0x00000]
我也试过 RestSharp.Monotouch 并得到类似的错误:
Ran out of trampolines of type 2 in '/private/var/mobile/Applications/A901C3E6-D9AB-44AF-AA13-6B6E44467BAE/StaffRostering.app/mscorlib.dll' (128)
Stacktrace:
at RestSharp.Reflection.SafeDictionary`2.GetEnumerator () <0x000ab>
at RestSharp.PocoJsonSerializerStrategy.TrySerializeUnknownTypes (object,object&) <IL 0x0002b, 0x00247>
at RestSharp.PocoJsonSerializerStrategy.SerializeNonPrimitiveObject (object,object&) <IL 0x00010, 0x000e7>
at RestSharp.SimpleJson.SerializeValue (RestSharp.IJsonSerializerStrategy,object,System.Text.StringBuilder) <IL 0x000f7, 0x00e1b>
at RestSharp.SimpleJson.SerializeObject (object,RestSharp.IJsonSerializerStrategy) <IL 0x0000e, 0x000eb>
at RestSharp.SimpleJson.SerializeObject (object) <IL 0x00006, 0x0008f>
at RestSharp.Serializers.JsonSerializer.Serialize (object) <IL 0x00001, 0x00083>