title: Deserialize dynamically named JSON objects in C# (using JSON.Net or otherwise)
body: <p>I have the following JSON:</p>
  
  <pre><code>{
  "aaaa": {
      "name": "General Name",
      "product": "book",
      "host": "book.example.com",
      "chapters": {
          "bbbb": {
              "name": "Chapter 1",
              "page": "1",
              "end_page": "25"
          }
      },
      "categories" : {
          "analysis":{
              "Abbbb" : {
                      "name": "B Chapter",
                      "id" : "9001"
              },
              "Acccc" : {
                      "name": "C Chapter",
                      "id" : "9001"
              },
              "Adddd" : {
                      "name": "D Chapter",
                      "id" : "9001"
              },
              "Aeeee" : {
                      "name": "E Chapter",
                      "id" : "9001"
              },
              "Affff" : {
                      "name": "F Chapter",
                      "id" : "9001"
              },
              "Agggg" : {
                      "name": "G Chapter",
                      "id" : "9001"
              }
          },
          "sources":{
              "acks" : {
                      "name": "S. Spielberg",
                      "id" : "9001"
              }
          }
      }
  }
  "yyyy": {
      "name": "Y General Name",
      "product": "Y book",
      "host": "ybook.example.com",
      ...
  }
  "zzzz": {
      "name": "Z General Name",
      "product": "Z book",
      "host": "zbook.example.com",
      ...
  }
  </code></pre>
  
  <p>The values for <code>aaaa</code>, <code>yyyy</code>, and <code>zzzz</code> can be any string and there can be any number of them. </p>
  
  <p>I need to extract all of the <code>[aaaa|yyyy|zzz].categories.analysis</code> values. That is, I need to end up with a <code>Dictionary&lt;string, string&gt;</code> of the <strong>object</strong> name (e.g., <code>Abbbb</code>, <code>Acccc</code>, etc.) and the ID, ignoring the <code>name</code> string. </p>
  
  <p>E.g.,
      [Abbbb, 9001]
      [Acccc, 9001]
      [Adddd, 9001]
      ...
      [Zaaaa, 9001]</p>
  
  <p>I've been at this for way too long and feel like I'm missing something obvious. I've tried JSON.net and native serialization. This is a trivial task in every other language I've used.</p>
  
  <p>I've come close with something like this:</p>
  
  <pre><code>var ajsonObject = JsonConvert.DeserializeObject&lt;dynamic&gt;(jsonString);
  var oasearch_categories = ajsonObject.aaaa.categories.analysis;
  </code></pre>
  
  <p>But again, <code>aaaa</code> can be any string, so I'm not sure how to reference that dynamically.</p>