无法解析字典值 [英] unable to parse dictionary values
问题描述
我正在尝试从json文件中解析字典,如下所示:
I am trying to parse a dictionary from a json file as follows
{
"appname":"App Name",
"taborder":[
"Street",
"Country"
],
"home":{
"type":"grid",
"items":[
"Street",
"Country"
]
}
}
起初我无法获得appname
和taborder
的详细信息,而我对此的疑问是
At first i am unable to get the details of appname
and taborder
and my question regarding it is here . I got a solution for there and by implementing it i got the values of taborder and appname
以同样的方式,我尝试按以下方式检索字典的值
In the same way i am trying to retrieve the value of a dictionary as follows
家":{ "type":网格", 项目":[ 约会", "reachus", ] }
"home":{ "type":"grid", "items":[ "appointments", "reachus", ] }
以下是我的代码
public class JavaScriptRequest
{
public string appname { get; set; }
public List<string> taborder { get; set; }
public Dictionary<string, string> home { get; set; }
}
JavaScriptRequest obj = DeserializeJavaScriptRequest(typeof(JavaScriptRequest), contents) as JavaScriptRequest;
MessageBox.Show(obj.appname+obj.home);
如何从字典中获取值,请帮助我
how to get the values from the dictionary, pls help me
推荐答案
尝试此类结构
public class JavaScriptRequest
{
public string appname { get; set; }
public string[] taborder { get; set; }
public JavaScriptRequest1 home { get; set; }
}
public class JavaScriptRequest1
{
public string type{get;set;}
public string[] items{get;set;}
}
这篇关于无法解析字典值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!