如何在 C# 中为这样的 json 数据编写 .net 对象?我不知道如何处理 startTime 和 endTime 字段。
{
"webinarKey":5303085652037254656,
"subject":"Test+Webinar+One",
"description":"Test+Webinar+One+Description",
"organizerKey":73563532324,
"times":[{"startTime":"2011-04-26T17:00:00Z","endTime":"2011-04-26T18:00:00Z"}]
}
我想先构建一个.net对象,然后我可以使用JavaScriptSerializer将它反序列化为.net对象。提前致谢。
最佳答案
看起来“times”属性应该是这样的:
public List<TimeRange> Times{get;set;}
...使用第二个类,如下所示:
public class TimeRange
{
public DateTime StartTime {get;set;}
public DateTime EndTime {get;set;}
}
关于c# - 为 json 数据编写 .net 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9197654/