我真的被难住了。这是我返回的 JSON:
{"ResponseData":[{"ClusterID":"c02f1f5c-c61b-4f2c-ab5a-249966b3cdef","ClusterName":"Northeast","Courses":[{"CourseID":"8ab4f2b3-8160-4d7e-b79f-8d8b58926cc0","CourseName":"Home Course","SubCourses":[{"SubCourseName":"SubCourse1","SubCourseNumber":18}]},{"CourseID":"b3223464-333b-4c54-89c2-23908e0510c9","CourseName":"Away Course","SubCourses":[{"SubCourseName":"SubCourse1","SubCourseNumber":19}]}],"IsHomeCluster":true},"ResponseErrors":[]}
这是我的反序列化代码:
JArray jArr = (JArray)JsonConvert.DeserializeObject(json);
foreach (var item in jArr) {
foreach (var subitem in item["ResponseData"]) {
Console.WriteLine (subitem ["ClusterID"]);
}
}
项目编译得很好,但是当我在模拟器中运行它时,我得到了这个错误:
System.TypeLoadException:发生类型加载异常。在 Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, Boolean checkAdditionalContent) [0x00000] 在 Newtonsoft.Json.JsonSerializer.DeserializeInternal (Newtonsoft.Json.JsonReader reader, System.在 Newtonsoft.Json.JsonSerializer.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] in :0 中键入 objectType) [0x00000] 在 Newtonsoft.Json.JsonConvert.DeserializeObject (System.String 值, System.Type 类型,Newtonsoft.Json.JsonSerializerSettings 设置)[0x00000] 在:0 在 Newtonsoft.Json.JsonConvert.DeserializeObject(System.String 值)[0x00000] 在:0 在 AppMultiView.CourseInformationScreen。
在 /Users/Dan/Desktop/AppTouch_dev /Main.cs:18 中的 AppMultiView.Application.Main (System.String[] args) [0x00000]
我是否试图反序列化错误的东西?
任何指针将不胜感激。