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; }
Angular, React, JavaScript, Java, PHP, SQL, C#, Vue, NodeJs, TypeScript and Interview Questions Answers