c# - Json Deserialization can't access attributes of object -
i got class (by using json2c#):
public class friends { public class datum { public string name { get; set; } public string id { get; set; } } public class paging { public string next { get; set; } } public class summary { public int total_count { get; set; } } public class rootobject { public list<datum> data { get; set; } public paging paging { get; set; } public summary summary { get; set; } } }
and poor try perfom deserialization:
datacontractjsonserializer js = new datacontractjsonserializer(typeof(friends)); memorystream ms = new memorystream(system.text.asciiencoding.ascii.getbytes(data)); friends x = (friends)js.readobject(ms);
i thought should able access example friends.datum.name not work.
my question is, did wrong? how should optimise code?
i got datatemplate listview , i'm using mvvm pattern, binding should no big issue.
this example json response:
{"data":[{"name":"xxx","id":"xxx"}],"paging":{"next":"https:\/\/graph.facebook.com\/v2.5\/xxx\/friends?access_token=x"},"summary":{"total_count":2}}
xxx secret
you have use deserializer type of rootobject
because has matching properties data
, paging
, summary
.
Comments
Post a Comment