title: How to read values from a nested json result in ASP.NET MVC
body: <p>I successfully got the result from <a href="https://jsonplaceholder.typicode.com/posts/1" rel="nofollow noreferrer">this</a> simple json and displayed in the view using the following code. </p>
  
  <blockquote>
    <p>SpeciesController.cs</p>
  </blockquote>
  
  <pre><code>using diversity.Models;
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.Mvc;
  using LinqToWiki.Download;
  using LinqToWiki.Generated;
  using LinqToWiki;
  using System.Text;
  using RestSharp;
  using Newtonsoft.Json.Linq;
  using System.Net.Http;
  using Newtonsoft.Json;
  
  namespace diversity.Controllers
  {
   public class SpeciesController : Controller
   {
    public async System.Threading.Tasks.Task&lt;ActionResult&gt; SpeciesDetails(){
  
      HttpClient client = new HttpClient();
      List&lt;Species&gt; datalist = new List&lt;Species&gt;();
  
      try
      {
          HttpResponseMessage response = await client.GetAsync("https://jsonplaceholder.typicode.com/posts/1");
          response.EnsureSuccessStatusCode();
          string responseBody = await response.Content.ReadAsStringAsync();
  
          datalist = JsonConvert.DeserializeObject&lt;List&lt;Species&gt;&gt;(responseBody);
      }
      catch (HttpRequestException e)
      {
          System.Diagnostics.Debug.WriteLine("\nException Caught!");
          System.Diagnostics.Debug.WriteLine("Message :{0} ", e.Message);
      }
      client.Dispose();
      return View(datalist);
     }
    }
   }
  </code></pre>
  
  <blockquote>
    <p>Species.cs</p>
  </blockquote>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  
  namespace diversity.Models
  {
    public class Species
    {
     public int UserId { get; set; }
     public int Id { get; set; }
     public string Title { get; set; }
     public string Body { get; set; }
    }
  }
  </code></pre>
  
  <blockquote>
    <p>SpeciesDetails.cshtml</p>
  </blockquote>
  
  <pre><code> @model IEnumerable&lt;diversity.Models.Species&gt;
  
   @{
     ViewBag.Title = "SpeciesDetails";
    Layout = "~/Views/Shared/_Layout.cshtml";
   }
  
  &lt;h2&gt;SpeciesDetails&lt;/h2&gt;
  
  &lt;p&gt;
     @Html.ActionLink("Create New", "Create")
  &lt;/p&gt;
  
   &lt;table class="table"&gt;
  &lt;tr&gt;
  &lt;th&gt;
      @Html.DisplayNameFor(model =&gt; model.UserId)
  &lt;/th&gt;
  &lt;th&gt;
      @Html.DisplayNameFor(model =&gt; model.Title)
  &lt;/th&gt;
  &lt;th&gt;
      @Html.DisplayNameFor(model =&gt; model.Body)
  &lt;/th&gt;
  &lt;th&gt;&lt;/th&gt;
  &lt;/tr&gt;
  
  @foreach (var item in Model) {
  &lt;tr&gt;
  &lt;td&gt;
      @Html.DisplayFor(modelItem =&gt; item.UserId)
  &lt;/td&gt;
  &lt;td&gt;
      @Html.DisplayFor(modelItem =&gt; item.Title)
  &lt;/td&gt;
  &lt;td&gt;
      @Html.DisplayFor(modelItem =&gt; item.Body)
  &lt;/td&gt;
  &lt;td&gt;
      @Html.ActionLink("Edit", "Edit", new { id=item.Id }) |
      @Html.ActionLink("Details", "Details", new { id=item.Id }) |
      @Html.ActionLink("Delete", "Delete", new { id=item.Id })
      &lt;/td&gt;
      &lt;/tr&gt;
     }
  
    &lt;/table&gt;
  </code></pre>
  
  <p>But now I want to display from <a href="http://api.gbif.org/v1/species/search?q=Puma&amp;rank=GENUS&amp;phylum=Chordata" rel="nofollow noreferrer">this</a> complex nested json result. Also I want to display only a few attributes such as 'family', 'genus' etc. I am aware of the question in <a href="https://stackoverflow.com/questions/23576726/using-readasasynct-to-deserialize-complex-json-object">here</a>. <strong>What is the proper way to do this in .NET HTTP Client?</strong> Then how should I modify my Model?</p>
  
  <pre><code>    {"offset":0,
    "limit":20,
    "endOfRecords":false,
    "count":49,
    "results":[{
      "key":104061090,
      "datasetKey":"fab88965-e69d-4491-a04d-e3198b626e52",
      "nubKey":2435098,
      "parentKey":104060851,
      "parent":"Felinae",
      "kingdom":"Metazoa",
      "phylum":"Chordata",
      "order":"Carnivora",
      "family":"Felidae",
      "genus":"Puma",
      "kingdomKey":103832354,
      "phylumKey":103882489,
      "classKey":104045725,
      "orderKey":104059711,
      "familyKey":104060843,
      "genusKey":104061090,
      "scientificName":"Puma",
      "canonicalName":"Puma",
      "authorship":"",
      "nameType":"SCIENTIFIC",
      "taxonomicStatus":"ACCEPTED",
      "rank":"GENUS",
      "origin":"SOURCE",
      "numDescendants":4,
      "numOccurrences":0,
      "habitats":[],
      "nomenclaturalStatus":[],
      "threatStatuses":[],
      "descriptions":[],
      "vernacularNames":[],
      "higherClassificationMap":{
        "103832354":"Metazoa",
        "103882489":"Chordata",
        "104045725":"Mammalia",
        "104059711":"Carnivora",
        "104060843":"Felidae",
        "104060851":"Felinae"
        },
      "synonym":false,
      "class":"Mammalia"
      }]
    }
  </code></pre>