I need to access data records from salesforce object. I got the json response.The json document is given below,
{
"totalSize":2,
"done":true,
"records":
[{"attributes":
{
"type":"Session__c",
"url":"/services/data/v20.0/sobjects/Session__c/a069000000RW12OAAT"
},
"Course__r":
{
"attributes":
{"type":"Course__c",
"url":"/services/data/v20.0/sobjects/Course__c/a079000000EqVgwAAF"
},
"Name":"aaaaaaaa",
"Type__c":"NetSuite"}},
{"attributes":
{
"type":"Session__c",
"url":"/services/data/v20.0/sobjects/Session__c/a069000000RW1ymAAD"
},
"Course__r":
{
"attributes":
{
"type":"Course__c",
"url":"/services/data/v20.0/sobjects/Course__c/a079000000EqVkOAAV"
},
"Name":"hhhhhhh",
"Type__c":"RubyonRails"}
}]
}
The use the following classes for in .net for deserializing it.
public class coursedetails
{
public string done { get; set; }
public string totalSize { get; set; }
public Records records { get; set; }
}
public class Records
{
public Attributes attributes{ get; set; }
public Cource_r Cource_r { get; set; }
public string Type_c { get; set; }
}
public class Cource_r
{
public string Name { get; set; }
public string Type_c { get; set; }
}
public class Attributes
{
public string type { get; set; }
public string url { get; set; }
}
/************* code for deserializing
JavaScriptSerializer ser1 = new JavaScriptSerializer();
record = ser1.Deserialize<coursedetails>(s);
But i cant deserialize it due to an error.An exception of type 'System.InvalidOperationException' occurred in System.Web.Extensions.dll but was not handled in user code
Additional information: Type 'connect+Records' is not supported for deserialization of an array.What is wrong with my code.