Skip to main content

Posts

Showing posts with the label JSON to list converter using C#

JSON to List converter generic method using C#

public List<T> GenericJSONToListConverter <T, C>(T t, dynamic c) {     List<T> responseList = new List<T>();     if (c.GetType() == typeof (Newtonsoft.Json.Linq.JObject))     {         T response = c.ToObject<T>();         responseList.Add(response);     }     else if (c.GetType() == typeof (Newtonsoft.Json.Linq.JArray))     {         responseList = c.ToObject<List<T>>();     }     return responseList; }