title: Convert JSON from GET request into text boxes in C# Winforms Application
body: <p>I am quite new to C# and I am looking for some help into the following.</p>
  
  <p>I have written some code (below) that utilises the companies house API to get information relating to companies. The information is returned in JSON format.</p>
  
  <p>What I need to do it take certain information and put it into text boxes I already have on the form. The code I have written works as I can get it to return in the message box but I can't work out how to populate it into text boxes.</p>
  
  <pre><code>private void getFromCompaniesHouse(object sender, EventArgs e)
      {
          try
          {
              //Compile request url
              string url = "https://api.companieshouse.gov.uk/company/" + txtCompanyNumber.Text;
  
              // Encode API key to ASCII
              string api_key = "yfhOb66cRn7ZL1VgdFjVur5cs8u6j__bcNnKj9Qs:";
              string encodedKey = Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(api_key));
  
              // Make get request using url and encoded API key
              HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
              request.Method = "GET";
              request.Headers.Add("Authorization", "Basic " + encodedKey);
              request.ContentType = "application/json; charset=utf-8";
  
              var response = (HttpWebResponse)request.GetResponse();
  
              using (var streamReader = new StreamReader(response.GetResponseStream()))
              {
                  MessageBox.Show(streamReader.ReadToEnd());
              }
          }
          catch
          {
              MessageBox.Show("Cannot Make Request", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
          }
      }
  </code></pre>
  
  <p>The JSON returned looks like this:</p>
  
  <pre><code>{  
  "accounts":{  
  "accounting_reference_date":{  
  "month":"12",
  "day":"31"
  },
  "last_accounts":{  
  "type":"group",
  "made_up_to":"2015-12-31"
  },
  "next_made_up_to":"2016-12-31",
  "next_due":"2017-09-30",
  "overdue":false
  },
  "company_number":"08867781",
  "annual_return":{  
  "last_made_up_to":"2016-06-20",
  "overdue":false
  },
  "jurisdiction":"england-wales",
  "has_been_liquidated":false,
  "date_of_creation":"2014-01-29",
  "undeliverable_registered_office_address":false,
  "company_name":"VIRGIN ATLANTIC LIMITED",
  "registered_office_address":{  
  "address_line_2":"Fleming Way",
  "locality":"Crawley",
  "country":"United Kingdom",
  "region":"West Sussex",
  "address_line_1":"Company Secretariat - The VHQ",
  "postal_code":"RH10 9DF"
  },
  "type":"ltd",
  "last_full_members_list_date":"2016-06-20",
  "sic_codes":[  
  "70100"
  ],
  "has_insolvency_history":false,
  "etag":"cbab10bb8b9dc1db442cb585a63ae208c1265100",
  "company_status":"active",
  "has_charges":false,
  "previous_company_names":[  
  {  
  "name":"VIRGIN ATLANTIC (HOLDINGS) LIMITED",
  "effective_from":"2014-01-29",
  "ceased_on":"2014-05-30"
  }
  ],
  "confirmation_statement":{  
  "next_made_up_to":"2017-06-20",
  "overdue":false,
  "next_due":"2017-07-04"
  },
  "links":{  
  "self":"/company/08867781",
  "filing_history":"/company/08867781/filing-history",
  "officers":"/company/08867781/officers"
  },
  "registered_office_is_in_dispute":false,
  "can_file":true
  }
  </code></pre>
  
  <p>** UPDATE **</p>
  
  <p>I have updated my code to the following:</p>
  
  <pre><code>private void getFromCompaniesHouse(object sender, EventArgs e)
      {
          try
          {
              //Compile request url
              string url = "https://api.companieshouse.gov.uk/company/" + txtCompanyNumber.Text;
  
              // Encode API key to ASCII
              string api_key = "yfhOb66cRn7ZL1VgdFjVur5cs8u6j__bcNnKj9Qs:";
              string encodedKey = Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(api_key));
  
              // Make get request using url and encoded API key
              HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
              request.Method = "GET";
              request.Headers.Add("Authorization", "Basic " + encodedKey);
              request.ContentType = "application/json; charset=utf-8";
  
              var response = (HttpWebResponse)request.GetResponse();
              var rawJson = new StreamReader(response.GetResponseStream()).ReadToEnd();
  
              var json = JObject.Parse(rawJson);  //Turns your raw string into a key value lookup
              string company_name = json["company_name"].ToObject&lt;string&gt;();
  
              txtBusinessName.Text = company_name;
  
          }
          catch
          {
              MessageBox.Show("Cannot Make Request", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
          }
      }
  </code></pre>
  
  <p>I can pull things from the <code>RootObject</code> class but cannot gain access to anything else for example in the <code>RegisteredOfficeAddress</code> class. Any ideas?</p>