这里是我的类反序列化复杂的字符串
class Respondents
{
public string ID { get; set; }
public string version { get; set; }
public string Status { get; set; }
public int Seed { get; set; }
public string Start { get; set; }
public string End { get; set; }
public string Duration { get; set; }
public Dictionary<string, string[]> Answers { get; set; }
public Respondents()
{
Answers = new Dictionary<string, string[]>();
}
}
和IM尝试使用下面的代码 - 反序列化它:
string jsonResp = File.ReadAllText(@"D:\JsonOutputFiles\Sample Survey.json");
obj = JsonConvert.DeserializeObject<Respondents>(jsonResp);
我不能做it.Need你的意见和建议
什么是你可能遇到的问题? – Ian
你可以发布JSON文本吗?当你说不能做到这一点时,你会得到一个错误吗?如果是这样,它是什么? – BuddhiP
{ “ID”: “Resp1”, “版本”: “版本”, “状态”: “部分”, “种子”:1, “开始”: “日期时间”, “结束”: “日期时间”, “持续时间”: “秒”, “答案”:{ “Q1”:{ “值”: “[email protected]” }, “Q2”:{ “值” :20 }, “Q3”:{ “值”:空 }, “Q4”:{ “值”: “5” }, “Q5”:{ “值”:100 }, “Q6”:{ “值”:[ “3”, “4” ] }, “Q7”:{ “值”:空 }, “Q8”:{ “值”:[ “4”, “5”, “8” ] }, “Q9”:{ “值”:空 } } } –