I am making some application with cryptocurrencies and I have a problem with API I have found somewhere.
I need some tips how to simplify my class for serialization.
public class Data
{
public SUB SUB { get; set; }
public USC USC { get; set; }
public DUX DUX { get; set; }
public XPS XPS { get; set; }
public EQT EQT { get; set; }
... //and a lot more of same classes
}
Here is that REST page with JSON
I have used http://json2csharp.com/ class generator - but after that I was left with hundreds of classes that looked the same - only had other names. I have tried replacing it but always was left with nulls.
Now I am with that:-
public class Data
{
public string Id { get; set; }
public string Url { get; set; }
public string ImageUrl { get; set; }
public string Name { get; set; }
...
}
public class RootObject
{
public string BaseLinkUrl { get; set; }
public List<List<Data>> Data { get; set; }
public int Type { get; set; }
}
public static async Task<T> DeserializeStringToObject<T>(string url)
{
return JsonConvert
.DeserializeObject<T>(await GetStreamFromUr(url));
}
Or maybe should I use different deserializer? Or just check for an object every time iterating for loop?