Steven Zack
Steven Zack

Reputation: 5104

write .net object for json data

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.

Upvotes: 3

Views: 150

Answers (1)

StriplingWarrior
StriplingWarrior

Reputation: 156524

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;}
}

Upvotes: 1

Related Questions