title: Get values from JSON result C#
body: <p>I am trying to get the values from a computer vision api result from reading text on an image using Azure. The output is JSON data but the syntax of the result looks strange.</p>
  
  <p>Ultimately I am trying to get the value "text" stripped out of it and written to a text file without any escape characters etc. </p>
  
  <p>Here is the code I am using the parse the result. </p>
  
  <pre><code>static async Task MakeOCRRequest(string imageFilePath)
  {
      try
      {
          HttpClient client = new HttpClient();
          client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", subscriptionKey);
          string requestParameters = "language=unk&amp;detectOrientation=true";
          string uri = uriBase + "?" + requestParameters;
          HttpResponseMessage response;
          byte[] byteData = GetImageAsByteArray(imageFilePath);
  
          using (ByteArrayContent content = new ByteArrayContent(byteData))
          {
              content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
              response = await client.PostAsync(uri, content);
          }
  
          string contentString = await response.Content.ReadAsStringAsync();
  
          ///////  It is at this point that I want to get the values from the "text" field
          JToken token = JToken.Parse(contentString).ToString();
          String[] result = contentString.Split(',');
          Console.writeline("\nResponse:\n\n{}\n", JToken.Parse(contentString).ToString());
  
      }
      catch (Exception e)
      {
          Console.WriteLine("\n" + e.Message);
      }
  }
  </code></pre>
  
  <p>And here is the result that I get from the OCR process. I havent included the full result as it represents over 1700 lines. </p>
  
  <pre><code>
    "language": "en",
    "textAngle": 0.0,
    "orientation": "Right",
    "regions": [
      {
        "boundingBox": "140,300,639,420",
        "lines": [
          {
            "boundingBox": "419,300,87,15",
            "words": [
              {
                "boundingBox": "419,300,87,15",
                "text": "0000175351"
              }
            ]
          },
          {
            "boundingBox": "140,342,337,47",
            "words": [
              {
                "boundingBox": "140,347,92,38",
                "text": "WE."
              },
              {
                "boundingBox": "241,347,13,36",
                "text": "1"
              },
              {
                "boundingBox": "266,342,211,47",
                "text": "0/1-1.9(2)"
              }
            ]
          },
  </code></pre>
  
  <p>With the current code I get the error message</p>
  
  <pre><code>JObject textResult = token["regions"]["text"].Value&lt;JObject&gt;();
  </code></pre>
  
  <blockquote>
    <p>Cannot access child value on <code>NewtonSoft.Json.Linq.JValue</code>. </p>
  </blockquote>
  
  <p>I wonder if I am requesting the wrong key?</p>