✅ How to deal with different JSON types

I have an API endpoint and depending on the query it can return a list of objects or an object as such:


Query for multiple
{"option": "1", "response":[{"A": "A"}, {"B": "B"}]}


Query for single
{"option": "1", "response":{"A": "A"}}


For now I'm only allowing queries for multiple but would like to support both.
    public class Response
    {
        public string A { get; set; }
        public string B { get; set; }
    }

    public class Root
    {
        public string option { get; set; }
        public List<Response> response { get; set; }
    }


Is there a way to support this?
Was this page helpful?