How to iterate through nested Dictionary<string, object>?
<p>I have a JSON file that I need to deserialize using the class <code>System.Web.Script.Serialization</code>. The following code: </p>

<pre><code>string json = File.ReadAllText(@"C:\file.json");
JavaScriptSerializer ser = new JavaScriptSerializer();
var dict = ser.Deserialize&lt;Dictionary&lt;string, object&gt;&gt;(json);
</code></pre>

<p>creates a nested dictionary, something like this:</p>

<pre><code>Dictionary&lt;string, Object&gt; outerDictionary;
Dictionary&lt;string, Object&gt; middleDictionary;
Dictionary&lt;string, string&gt; innerDictionary;
</code></pre>

<p>I now need to grab some of the values from the innerDictionary into a C# object class, like:</p>

<pre><code>public class Location
{
   public string Id { get; set; }
   public string Name { get; set; }
   public string Street { get; set; }
   public string City { get; set; }
   public string State { get; set; }
   public string Zip { get; set; }
}
</code></pre>

<p>So my question is, how can I iterate over the nested disctionary to get the values I need at the innermost level?</p>

<p><strong>UPDATE</strong></p>

<p>With the help of <code>Jonesopolis</code> I now have the correct loop structure, but I am still unable to get the values from the innermost dictionary?</p>

<pre><code>foreach (var outer in dict)
{
    foreach (var middle in (Dictionary&lt;string, object&gt;)outer.Value)
    {
        foreach (var inner in (ArrayList)middle.Value)
        {
            foreach (var loc in (Dictionary&lt;string, object&gt;)inner)
            {
            }
         }
    }
}
</code></pre>