title: How to convert a dictionary pair.value to a dictionary in C#?
body: <p>i have the following JSON in my application.</p>
  
  <pre><code>string json = @"{""dest"":[ { ""mode"": ""1"", ""test"":""test1,test,test2""},{ ""mode"": ""2"", ""test"": ""test3"" }]}";
  </code></pre>
  
  <p>To get the value of <strong>dest</strong> I m using the following method.</p>
  
  <pre><code> var json_serializer = new JavaScriptSerializer();
              Dictionary&lt;string, object&gt; dictionary = json_serializer.Deserialize&lt;Dictionary&lt;string, object&gt;&gt;(json);
  
       public Dictionary&lt;string, object&gt; GetObject(Dictionary&lt;string, object&gt; view, string name)
              {
                  Dictionary&lt;string, object&gt; result = new Dictionary&lt;string, object&gt;();
                  object value = null;
                  foreach (KeyValuePair&lt;string, object&gt; pair in view)
                  {
                      Type type = pair.Value.GetType();
                      if (pair.Key == name)
                      {
                          **Dictionary&lt;string, object&gt; child = (System.Collections.Generic.Dictionary&lt;string, object&gt;)pair.Value;**
                          result = GetObject(child, name);
                          if (result != null)
                          {
                              break;
                          }
                      }
                      else
                      {
                      }
                  }
                  return result;
              }
  </code></pre>
  
  <p>I m getting error in the line  <strong>Dictionary child = (System.Collections.Generic.Dictionary)pair.Value;</strong>. 
  The error says "Unable to cast object of type 'System.Collections.ArrayList' to type 'System.Collections.Generic.Dictionary`2[System.String,System.Object]'."</p>
  
  <p>Anyone knows how to fix this?</p>