This question is probably asked a dozen times but i can't find anything useful so...
JSON data looks like this
{
"aaData": [
[
8120,
"username",
"[email protected]",
"\/",
"CUSTOMER ( SellerName )",
"name",
"<span class=\"label label-danger\">2015-08-05<\/span>",
"<a class=\"btn btn-xs btn-primary manageDevices\" href=\"#\" id=\"manageDevices\" data-customerid=\"8120\" data-toggle=\"modal\">1<\/a>",
"<a id=\"8120\" href=\"http:\/\/cms.*********.com:8081\/manageCustomers?customerId=8120\" class=\"btn btn-xs btn-primary\">View<\/a>",
"YES"
],
....
]
],
"sEcho": "NULL",
"iTotalRecords": 65,
"iTotalDisplayRecords": 65
}
Obviously, this fails:
private class OuterUser
{
string id { get; set; }
string username { get; set; }
string line { get; set; }
string reseller { get; set; }
string username2 { get; set; }
string date1 { get; set; }
string manage { get; set; }
string manageUser { get; set; }
string active { get; set; }
}
dynamic jsonDe = JsonConvert.DeserializeObject<OuterUser>(rpl);
//dynamic j = JsonConvert.DeserializeObject<List<OuterUser>>(rpl);
Anyone has idea how to deserialize this? And explain what i did wrong. I don't need data on bottom (total records) and so on. Actually, only thing that i need is ID on beginning, username and email. Commented code also fails and i think that is part of solution.
JsonConvert.DeserializeObject<OuterUser[]>(rpl);as you wrote you need a array. Is there any container object?An exception of type 'Newtonsoft.Json.JsonSerializationException' occurred in Newtonsoft.Json.dll but was not handled in user code Also, i think that this "aaData" is some kind of container with rest of those users... Additional information: Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'tvTracker.Data.IPTV+OuterUser[]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.I need a list of those users, or array. Anything.