c# - getting null while deserialization json -
i trying deserialize web response json object, @ time object gettingnull
after deserialization. code:
json response:
{ "@odata.context": "https://outlook.office365.com/api/v1.0/$metadata#me/calendarview", "value": [ { "@odata.id": "https://outlook.office365.com/api/v1.0/users('sathesh@newtechsolution.onmicrosoft.com')/events('aamkadqzmgvmnjzmlwy1yjatngfkys1hody0ltdimwzlzjzjymiwoabgaaaaaaaaluoeh9c2qq33mvktcqzgbwd1qtj3io57qawz9mzf6weaaaaaaaenaad1qtj3io57qawz9mzf6weaaaaaaa0kaaa=')", "@odata.etag": "w/\"9ue49ydue0glmftgreshmgaaaaanag==\"", "id": "aamkadqzmgvmnjzmlwy1yjatngfkys1hody0ltdimwzlzjzjymiwoabgaaaaaaaaluoeh9c2qq33mvktcqzgbwd1qtj3io57qawz9mzf6weaaaaaaaenaad1qtj3io57qawz9mzf6weaaaaaaa0kaaa=", "changekey": "9ue49ydue0glmftgreshmgaaaaanag==", "categories": [], "datetimecreated": "2015-05-20t12:03:09.4043813z", "datetimelastmodified": "2015-05-20t12:03:09.5606394z", "subject": "interview sample", "bodypreview": "interview api discussion.", "body": { "contenttype": "html", "content": "<html>\r\n<head>\r\n<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">\r\n<style type=\"text/css\" style=\"display:none;\"><!-- p {margin-top:0;margin-bottom:0;} --></style>\r\n</head>\r\n<body dir=\"ltr\">\r\n<div id=\"divtagdefaultwrapper\" style=\"font-size:12pt;color:#000000;background-color:#ffffff;font-family:calibri,arial,helvetica,sans-serif;\">\r\n<p>interview api discussion.<br>\r\n</p>\r\n</div>\r\n</body>\r\n</html>\r\n" }, "importance": "normal", "hasattachments": false, "start": "2015-05-20t16:00:00z", "starttimezone": "sri lanka standard time", "end": "2015-05-20t17:00:00z", "endtimezone": "sri lanka standard time", "reminder": 15, "location": { "displayname": "interview sample chennai mrc nagar", "address": { "street": "", "city": "", "state": "", "countryorregion": "", "postalcode": "" }, "coordinates": { "accuracy": "nan", "altitude": "nan", "altitudeaccuracy": "nan", "latitude": "nan", "longitude": "nan" } }, "responsestatus": { "response": "organizer", "time": "0001-01-01t00:00:00z" }, "showas": "busy", "isallday": false, "iscancelled": false, "isorganizer": true, "responserequested": true, "type": "singleinstance", "seriesmasterid": null, "attendees": [ { "emailaddress": { "address": "skumar@viswambara.com", "name": "skumar@viswambara.com" }, "status": { "response": "none", "time": "0001-01-01t00:00:00z" }, "type": "required" } ], "recurrence": null, "organizer": { "emailaddress": { "address": "sathesh@newtechsolution.onmicrosoft.com", "name": "sathesh kumar" } }, "icaluid": "040000008200e00074c5b7101a82e0080000000019d340f0f492d0010000000000000000100000005ba1b6261eecd34d991c5be7d4a70547" } ] }
class:
public class value { public string id { get; set; } public string changekey { get; set; } public list<object> categories { get; set; } public string datetimecreated { get; set; } public string datetimelastmodified { get; set; } public string subject { get; set; } public string bodypreview { get; set; } public body body { get; set; } public string importance { get; set; } public bool hasattachments { get; set; } public string start { get; set; } public string starttimezone { get; set; } public string end { get; set; } public string endtimezone { get; set; } public int reminder { get; set; } public location location { get; set; } public responsestatus responsestatus { get; set; } public string showas { get; set; } public bool isallday { get; set; } public bool iscancelled { get; set; } public bool isorganizer { get; set; } public bool responserequested { get; set; } public string type { get; set; } public object seriesmasterid { get; set; } public list<attendee> attendees { get; set; } public object recurrence { get; set; } public organizer organizer { get; set; } public string icaluid { get; set; } }
deserialization:
javascriptserializer json = new javascriptserializer(); value condiiton = (value)json.deserialize(responcedata, typeof(value));
let's @ json object. have anonymous json (let's call response
) object 2 objects: string '@odata.context' , array 'value' of objects of value
c# class type.
you have described value
class trying deserialize response
object value
incorrect.
need describe corresponding class , deserialize it.
public class response { public value[] value { get; set; } }
then can way:
javascriptserializer json = new javascriptserializer(); response response = (response)json.deserialize(responcedata, typeof(response));
Comments
Post a Comment