0

我有一本这样的字典

{
  "A" : {
    "A1" : {
      "er" : false,
       "hy" : false,
       "fv" : false,
       "fr" : false
          },
     "A2" : {
       "fr" : false,
       "ty" : false,
       "ty" : false,
          },
   "B" : {
     "B1" : {
       "er" : false,
       "hy" : false,
       "fv" : false,
       "fr" : false
         },
     "B2" : {
      "fr" : false,
      "ty" : false,
      "ty" : false,
   },
  }
}

我正在尝试将 A1 和 A2 字典的值作为单独的字典检索

我努力了

 Dictionary<string, Dictionary<string, object>> dict =
 jss.Deserialize<Dictionary<string, Dictionary<string, object>>>json.ToString());

       Dictionary<string, object> dict1 = dict["A"];

 Dictionary<string, object> dict2 = dict1["A1"];//error here

无法将类型“object”隐式转换为“System.Collections.Generic.Dictionary”。存在显式转换(您是否缺少演员表?)

如何解决这个问题?

4

1 回答 1

1

我认为这将解决它:

Dictionary<string, object> dict2 = (Dictionary<string, object>) dict1["A1"];

于 2012-10-12T10:10:19.440 回答