I have JSON like this
{
"rates": {
"2018-05-04": {
"USD": 0.2813388807,
"GBP": 0.2074019228
},
"2018-08-27": {
"USD": 0.2723718099,
"GBP": 0.2115780848
}
...etc etc
},
"start_at": "2018-01-01",
"base": "PLN",
"end_at": "2018-09-01"
}
I want to map it to C# object. I tried to use json@csharp, but it gives me something like this
public class __invalid_type__20180504
{
public double USD { get; set; }
public double GBP { get; set; }
}
public class __invalid_type__20180827
{
public double USD { get; set; }
public double GBP { get; set; }
}
public class Rates
{
public __invalid_type__20180504 __invalid_name__2018-05-04 { get; set; }
public __invalid_type__20180827 __invalid_name__2018-08-27 { get; set; }
}
public class RootObject
{
public Rates rates { get; set; }
public string start_at { get; set; }
public string @base { get; set; }
public string end_at { get; set; }
}
I do not want to have class names like "__invalid_type__xxxxxxxx", and I am looking for a way to map it to one class so that I have list of one class type. I am using DataContractJsonSerializer
and System.Net.Http.HttpClient