In my C# code I am calling an endpoint which sends back the structure something similar to this
{
"name":"test",
"clients": {
"client1": {"id": "1", "count": "41"},
"client2": {"name": "testName"},
"client3": {"CustomerID": "a1", "internalID": "testID"}
}
}
I need to convert this to a C# object and then iterate through the "clients". The problem is that beforehand I do not know the client names (in the above example "client1", "client2", and "client3") or the number of clients that can come back.
So in my code I have the following C# file
public class result
{
public string name { get; set; }
[JsonProperty("clients")]
public string[] clients { get; set; }
}
However when I try to parse this using JsonConvert.DeserializeObject I get an error. Ideally what I would like to do is to convert the clients into a C# array and then iterate though them.