title: Deserialize JSON data in to a class in c#
body: <p>hello people I have this Json data:
  <a href="https://openexchangerates.org/api/latest.json?app_id=6cf59607a32d408eb3e04de1427a3169" rel="nofollow noreferrer">https://openexchangerates.org/api/latest.json?app_id=6cf59607a32d408eb3e04de1427a3169</a></p>
  
  <p>and I want to deserialize in the following class  </p>
  
  <pre><code> using Newtonsoft.Json;
  using System.Collections.Generic;
  
  namespace Divisas2MVVM2.Classes
  
  {
  public class ExchangeRates
  {
      [JsonProperty(PropertyName = "disclaimer")]
      public string Disclaimer { get; set; }
  
      [JsonProperty(PropertyName = "license")]
      public string License { get; set; }
  
      [JsonProperty(PropertyName = "timestamp")]
      public int TimeStamp { get; set; }
  
      [JsonProperty(PropertyName = "base")]
      public string Base { get; set; }
  
      [JsonProperty(PropertyName = "rates")]
      public Rates Rates { get; set; }
  }
  
  public class Rates
  {
      public double AED { get; set; }
      public double AFN { get; set; }
      public double ALL { get; set; }
      public double AMD { get; set; }
      // I cut the text so that it would not be to long
      public double ZMW { get; set; }
      public double ZWL { get; set; }
  }
  
  public class Rate
  {
      public double TaxRate { get; set; }
  
      public string Code { get; set; }
  }
  </code></pre>
  
  <p>this is my attribute</p>
  
  <pre><code> private ExchangeRates exchangeRates;
  </code></pre>
  
  <p>the constructor of my MainViewModel </p>
  
  <pre><code>new ObservableCollection data
  Rates = new ObservableCollection&lt;Rate&gt;();
  </code></pre>
  
  <p>and in this method a get the json data</p>
  
  <pre><code> try
          {
              var client = new HttpClient();
              client.BaseAddress = new Uri("https://openexchangerates.org");
              var url = "/api/latest.json?app_id=6cf59607a32d408eb3e04de1427a3169";
              var response = await client.GetAsync(url);
  
              if (!response.IsSuccessStatusCode)
              {
                  Message = response.StatusCode.ToString();
                  IsRunning = false;
                  return;
              }
  
              var result = await response.Content.ReadAsStringAsync();
              exchangeRates = JsonConvert.DeserializeObject&lt;ExchangeRates&gt;(result);
  
          }
  </code></pre>
  
  <p>everything works fine, the variable result has correctly the json data in a string format, but when i call JsonConvert . DeserializeObject, the data "rates" it is not assigned correctly, all the other data: disclaimer", "license", "timestamp" etc. is correctly assigned. only rates fail.</p>
  
  <p><a href="https://i.stack.imgur.com/h2CCL.png" rel="nofollow noreferrer">the string is correct</a></p>
  
  <p><a href="https://i.stack.imgur.com/mDbYI.png" rel="nofollow noreferrer">other data is correct in the class</a></p>
  
  <p><a href="https://i.stack.imgur.com/dxQDG.png" rel="nofollow noreferrer">rates is incorrect</a></p>
  
  <p>sorry for my English I hope you have understood me :)</p>