title: How would I return a specific json value which has duplicate keys
body: <p>I have the following JSON</p>
  
  <pre><code>{
    "nest1" : {
      "attributes" : {
        "type" : "irrelevant",
        "url" : "irrelevant"
      },
      "key" : "value1"
    },
    "nest2" : {
      "attributes" : {
        "type" : "irrelevant",
        "url" : "irrelevant"
      },
      "key" : "value2"
    }
  }
  </code></pre>
  
  <p>I have tried something like below to grab the value for the second<code>key</code>, but this throws an <code>InvalidOperationException</code>. with the following error message: </p>
  
  <blockquote>
    <p>Cannot access child value on Newtonsoft.Json.Linq.JProperty.</p>
  </blockquote>
  
  <pre><code>string value = getJson(json, "key");
  </code></pre>
  
  <p>The method looks like</p>
  
  <pre><code>public string getJson(string json, string name)
      {
         JObject token = JObject.Parse(json);
         JToken jtoken = token.Last.ToString();
         return jtoken[name].toString();
      }
  </code></pre>
  
  <p>I'm guessing there is probably something simple i'm forgetting, any help would be great</p>