title: Deserialize object using JSON.NET without the need for a container
body: <p>I am using JSON.NET to deseralize JSON strings that I receive from a service to my business objects.</p>
  
  <p>I have a nice Service pattern that parses all my JSON strings from a given REST URL to an object as follows:</p>
  
  <pre><code>private async Task&lt;T&gt; LoadJSONToObject&lt;T&gt;(string url)
  {
      //get data
      var json = await GetResultStringAsync(url);
  
      //deserialize it
      var results = JsonConvert.DeserializeObject&lt;T&gt;(json);
      return results;
  }
  </code></pre>
  
  <p>The challenge that I am having is how do I use the above pattern with collections without creating a "container" class.</p>
  
  <p>For example, if I am getting the following JSON back:</p>
  
  <pre><code>{
      "Properties": [
          {
              "id": 1,
              "name": "Property Name A",
              "address": "Address A, City, Country",
          },
          {
              "id": 2,
              "name": "Property Name B",
              "address": "Address B, City, Country",
          }
      ]
  }
  </code></pre>
  
  <p>And my business entity is as follows:</p>
  
  <pre><code>public class Property
  {
      [JsonProperty("id")]
      public string ID { get; set; }
  
      [JsonProperty("name")]
      public string Name { get; set; }
  
      [JsonProperty("address")]
      public string Address{ get; set; }
  
  }
  </code></pre>
  
  <p>I would like to simply invoke my above method by calling:</p>
  
  <pre><code>LoadJSONToObject&lt;List&lt;Property&gt;&gt;("http://www.myapi.com/properties");
  </code></pre>
  
  <p>The above fails because JSON.NET is expecting a container object instead. Something like:</p>
  
  <pre><code>public class PropertyList 
  {
      [JsonProperty("Properties")]
      public List&lt;Property&gt; Properties { get; set; }
  }
  </code></pre>
  
  <p>I think it's an overkill to create such a container and want to see if there is an elegant solution to do the above.</p>