¿Cómo crear correctamente un modelo para la deserialización json?

¿Cómo deserializar un JSON en objetos C#?

Este es mi JSON:

{
    "date": "2020-07-02 10:39:00+00",
    "base": "USD",
    "rates": {
        "FJD": 2.1692,
        "MXN": 22.602,
      [...]
    }
}

modelo raíz

public class BaseCurrencyModel
{
    public DateTime Date { get; set; }
    public string Base { get; set; }
    public IEnumerable<RatesModel> Rates { get; set; }
}

Objeto para valores de matriz:

public class RatesModel
{
    public string currencyCode { get; set; }
    public string rate { get; set; }
}

cuando uso

public Dictionary<string, string> Rates 

en el modelo raíz todo funciona bien. si uso

IEnumerable<RatesModel> Rates

me sale el error

Cannot deserialize the current JSON object into type 'System.Collections.Generic.IEnumerable`1[CurrencyConverter.Models.RatesModel]'because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
To fix this error either change the JSON to a JSON array

Answer

las tasas json no son una matriz, es un diccionario

public class BaseCurrencyModel
{
    public DateTime Date { get; set; }

    public string Base { get; set; }

    public Dictionary<string,double> Rates { get; set; }
}

o puedes convertirlo a Lista

    var ratesParsed= JObject.Parse(json);
    BaseCurrencyModel rates = new BaseCurrencyModel
    {
        Date = ratesParsed["date"].ToObject<DateTime>(),
        Base = (string)ratesParsed["base"],
        Rates = ((JObject)ratesParsed["rates"]).Properties().Select(x => 
                   new RatesModel { currencyCode = x.Name, 
                   rate = Convert.ToDouble(x.Value) }
                ).ToList()
    };

clase

public class BaseCurrencyModel
{
    public DateTime Date { get; set; }

    public string Base { get; set; }

    public List<Rate> Rates { get; set; }
}

salida (en formato json)

{
  "Date": "2020-07-02T08:09:00-02:30",
  "Base": "USD",
  "Rates": [
    {
      "currencyCode": "FJD",
      "rate": 2.1692
    },
    {
      "currencyCode": "MXN",
      "rate": 22.602
    }
  ]
}