title: Json.NET - deserialize directly from a stream to a dynamic?
body: <p>With a little help from the <a href="http://james.newtonking.com/json/help/index.html?topic=html/Performance.htm" rel="noreferrer">performance tips</a> in the Json.NET docs, I put together a method for downloading/deserializing JSON from a remote resource:</p>
  
  <pre><code>public async Task&lt;T&gt; GetJsonAsync&lt;T&gt;(string url) 
  {
    using (var stream = await new HttpClient().GetStreamAsync(url))
    {
      using (var sr = new StreamReader(stream))
      {
        using (var jr = new JsonTextReader(sr))
        {
          return new JsonSerializer().Deserialize&lt;T&gt;(jr);
        }
      }
    }
  }
  </code></pre>
  
  <p>I'd like to have a non-generic version that returns a <code>dynamic</code>. Calling the above method with <code>GetJsonAsync&lt;dynamic&gt;(url)</code> works, until you try to access a dynamic property on the result, at which point I get:</p>
  
  <pre><code>'Newtonsoft.Json.Linq.JObject' does not contain a definition for '[MyProperty]'
  </code></pre>
  
  <p>I have seen <a href="https://stackoverflow.com/questions/4535840/deserialize-json-object-into-dynamic-object-using-json-net">how to deserialize to a dynamic</a> from a string, but have not seen a working example of doing it directly from a stream, which would be preferable as it is more memory efficient. Is this possible?</p>