我有一个像
{
"appStatus":{
"status":true
},
"lastSyncDate":"06-07-2013 13.54.27",
"configResponse":{
"status":{
"status":true
},
"configs":{
"APPLOGENABLED":{
"configCode":"APPLOGENABLED",
"configDesc":"enable or disable logging from front end",
"configType":"TAB",
"configValue":"Y"
},
"COMMENTSTIMER":{
"configCode":"COMMENTSTIMER",
"configDesc":"timer for comments in seconds",
"configType":"TAB",
"configValue":"60"
},
"SUMMARYTIMER":{
"configCode":"SUMMARYTIMER",
"configDesc":"timer for summary in seconds",
"configType":"TAB",
"configValue":"30"
},
"ALERTSTIMER":{
"configCode":"ALERTSTIMER",
"configDesc":"timer for alerts in seconds",
"configType":"TAB",
"configValue":"60"
}
},
"lastSyncDate":"06/07/2013 13.48.13"
}
}
使用 json.NET,我想提取configResponse
到字典中。我知道我可以像这样直接转换 Dictionary 对象
JsonConvert.DeserializeObject<Dictionary<string,string>>()....
但由于configResponse
是一个子元素,我无法根据需要解析它。
我想将上面的 json 响应反序列化为
public class ConfigResponse
{
public Status status { get; set; }
public Dictionary<string, ConfigurationItem> configs { get; set; }
public string lastSyncDate { get; set; }
}
public class ConfigurationItem
{
public String configCode { get; set; }
public String configDesc { get; set; }
public String configType { get; set; }
public String configValue { get; set; }
}