title: JsonConvert.DeserializeObject<T> returning null
body: <p>I have an app that I would like to store some email setting in a json file.</p>
  
  <p>The json file looks like:</p>
  
  <pre><code>{
  "Id": 1,
  "From": "myemail@whereever.com",
  "Password": "mypassword",
  "Port": 587,
  "To": "myemail@whereever.com",
  "SmtpAddress": "smtp.office365.com",
  "TargetName": "STARTTLS/smtp.office365.com"
  }
  </code></pre>
  
  <p>and C# code looks like :</p>
  
  <pre><code>public class EmailModel
  {
      [JsonProperty(nameof(Id))]
      public int Id { get; set; }
      [JsonProperty(nameof(To))]
      public string To { get; set; }
      [JsonProperty(nameof(From))]
      public string From { get; set; }
      [JsonProperty(nameof(Port))]
      public int Port { get; set; }
      [JsonProperty(nameof(Password))]
      public string Password { get; set; }
      [JsonProperty(nameof(SmtpAddress))]
      public string SmtpAddress { get; set; }
      [JsonProperty(nameof(TargetName))]
      public string TargetName { get; set; }
  }
  </code></pre>
  
  <p>and accessing it looks like:</p>
  
  <pre><code>public EmailModel EmailModel(int id)
  {
      var filePath = AppDomain.CurrentDomain.BaseDirectory;
  
      using (var sr = new StreamReader(Path.Combine(filePath,"appsettings.json")))
      {
          string json = sr.ReadToEnd();
          return JsonConvert.DeserializeObject&lt;EmailModel&gt;(json);
      }
  }
  </code></pre>
  
  <p>I have seen many posts for this, however none seem to work. I have added </p>
  
  <pre><code>var settings = new JsonSerializerSettings();
  settings.MetadataPropertyHandling = MetadataPropertyHandling.Ignore;
  </code></pre>
  
  <p>in the EmailModel class and still all my values still end up null. </p>
  
  <p><strong>Update</strong>
  debugging through this I see that <code>sr.ReadToEnd()</code> returns:</p>
  
  <pre><code> "{\r\n  \"EmailModel\": {\r\n    \"Id\": 1,\r\n    \"From\": \"myemail\",\r\n    \"Password\": \"myPassword\",\r\n    \"Port\": 587,\r\n    \"To\": \"myEmail\",\r\n    \"SmtpAddress\": \"smtp.office365.com\",\r\n    \"TargetName\": \"STARTTLS/smtp.office365.com\"\r\n  }\r\n}\r\n"
  </code></pre>
  
  <p>}</p>
  
  <p><strong>Update 2:</strong>
  I get a reply from appsetting.json and when I change code from </p>
  
  <pre><code>var filePath = AppDomain.CurrentDomain.BaseDirectory;
              var streamPath = Path.Combine(filePath, "appsettings.json");
              string json = null;
              using (var sr = new StreamReader(streamPath))
              {
                  json = sr.ReadToEnd();
  
              }
  </code></pre>
  
  <p>to:</p>
  
  <pre><code>        var json = @"
              {
              ""Id"": 1,
              ""From"": ""myEmail"",
              ""Password"": ""myPassword"",
              ""Port"": 587,
              ""To"": ""myEmail"",
              ""SmtpAddress"": ""smtp.office365.com"",
              ""TargetName"": ""STARTTLS/smtp.office365.com""
              }";
  </code></pre>
  
  <p>my test doesnt fail.</p>