1

I am parsing a JSON response from Citrix' web services. The response looks like this

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

I manually edited that string to remove identifying information, so if there is a missing quote or anything it is unrelated.

I followed the example from this answer on SO, but still am encountering an error.

Deserializing JSON result with Json & JavaScriptSerializer

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

I receive the following error: Type 'Web.Site.Webinars' is not supported for deserialization of an array.

4
  • If I'm not wrong you need to use jss.Deserialize<IList<Webinars>>(JSON) Commented May 4, 2012 at 15:59
  • @ClaudioRedi - that certainly helped, resolved first error, now new error is WebinarTimes is not supported for deserialization of an array. Commented May 4, 2012 at 16:01
  • @ClaudioRedi - fixed, if you post as answer I will accept. Had to modify Webinars to include WebinarTimes as an array. Commented May 4, 2012 at 16:02
  • 1
    Posted as an answer. Glad it helped :) Commented May 4, 2012 at 16:05

1 Answer 1

2

You have to use IList<Webinars> instead of Webinars

var foo = jss.Deserialize<IList<Webinars>>(JSON);
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.