我正在解析来自 Citrix 的 Web 服务的 JSON 响应。响应看起来像这样
[{\"webinarKey\":123456,\"subject\":\"Subject\",\"description\":\"Webinar Description. \",\"organizerKey\":123456,\"times\":[{\"startTime\":\"2012-05-08T16:00:00Z\",\"endTime\":\"2012-05-08T17:00:00Z\"}],\"timeZone\":\"America/New_York\"}]
我手动编辑了该字符串以删除识别信息,因此如果缺少引号或任何不相关的内容。
我在 SO 上按照这个答案中的示例进行操作,但仍然遇到错误。
使用 Json 和 JavaScriptSerializer 反序列化 JSON 结果
public class Webinars {
public string webinarKey;
public string subject;
public string description;
public string organizerKey;
public WebinarTimes[] times;
public string timeZone;
}
public class WebinarTimes {
public string startTime;
public string endTime;
}
JavaScriptSerializer jss = new JavaScriptSerializer();
var foo = jss.Deserialize<Webinars>(JSON);
我收到以下错误:Type 'Web.Site.Webinars' is not supported for deserialization of an array.