When I can call the 3rd party api and get back a single class worth of data everything deserialises fine using this code
TheUser me = jsonSerializer.Deseria
This solution seems to work for me and gets around having to code a bunch of classes with "Data" in them.
public interface IDataResponse<T> where T : class
{
List<T> Data { get; set; }
}
public class DataResponse<T> : IDataResponse<T> where T : class
{
[JsonProperty("data")]
public List<T> Data { get; set; }
}
I should have included this to begin with, here is an example method using the above:
public List<TheUser> GetUser()
{
var results = GetUserJson();
var userList = JsonConvert.DeserializeObject<DataResponse<TheUser>>(results.ToString());
return userList.Data.ToList();
}
try
List<TheUser> friends = jsonSerializer.Deserialize<List<TheUser>>(response);