I have done this before and I usually am goof to determine what is wrong with my JSON object or my code, but I can't seem to understand what I am doing wrong. I have even used Jsontocharp.com and it gives me the result I expect.
Here is my json:
{"user":[{"ID":"12393","userID":"4772","username":"bullyboy","dtDate":"2020-11-02
17:26:54.277}],"actions":[{"actionsID":"23983","actionsName":"Clicked","ObjectName":"Button"},{"actionsID":"23984","actionsName":"Submitted","ObjectName":"Form"} ], "Deleted":[],"Forms":[],"Timestamp":"2020-11-06 13:45:28"}
my Root is:
public class Root
{
public List<Users> user { get; set; }
public List<Actions> actions { get; set; }
public List<DeletedData> Deleted { get; set; }
public List<CMForms> Forms { get; set; }
public string Timestamp { get; set; }
}
my deserializer is as follows
response = client.PostAsync(url, params).Result;
if(response.StatusCode == HttpStatusCode.OK)
{
var content = await response.Content.ReadAsStringAsync();
Root jsonList = JsonConvert.DeserializeObject<Root>(content);
foreach(var act in jsonList.actions)
{
Console.WriteLine(act);
}
I am getting the error message listed above. I'm not sure what I am doing incorrectly. By the way the empty lists are because nothing resulted for that user.I have to take that into account. If the list is empty I simply skip over it, but I can't even deserialize my list..
What I have tried:
I can't change what is being submitted to me aka the JSON so I I have tried making my Root as a list and it doesn't give me that room but that isn't what I want because what I am returning is not a list.. right? At least I am viewing it as an object and inside that object I have lists.