Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

write .net object for json data

Tags:

json

c#

.net

How to write a .net object for such a json data in c#? I don't know how to deal with startTime and endTime fields.

 {
 "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"}]
 }

I want to build a .net object first, then I can use JavaScriptSerializer to Deserialize it into the .net object. Thanks in advance.

like image 557
Steven Zack Avatar asked Nov 20 '25 18:11

Steven Zack


1 Answers

It looks like the "times" property should look like this:

public List<TimeRange> Times{get;set;}

... which uses a second class that looks like this:

public class TimeRange
{
    public DateTime StartTime {get;set;}
    public DateTime EndTime {get;set;}
}
like image 166
StriplingWarrior Avatar answered Nov 23 '25 06:11

StriplingWarrior



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!