I would highly recommend you stop using dynamic
because I think this is an abuse of the type. Instead I would define types to deserialize into. By doing so you give yourself type safety and working with the data becomes trivial. Below are class definitions an example using the generic deserialize method (Deserialize<T>(string input)
).
public class order
{
public int id { get; set; }
public string type { get; set; }
public string symbol { get; set; }
public string side { get; set; }
}
public class orders
{
List<order> order { get; set; }
}
JsonSerializer serializer = new JsonSerializer();
orders myOrders = serializer.Deserialize<orders>(response);
if (myOrders.order.Count() == 1)
// we have 1 order