1
我能够得到一个JSON对象,其中包含一组具有每组属性的调查列表。我有一个为调查定义的类,我根据获取的JSON对象定义所有调查属性。我在定义question.id属性时遇到错误。请建议我解决此问题的最佳方法。如何根据获取的JSON对象为类定义属性?
JSON数据:
"surveys":
{
"id": 20128672,
"trueFalse": false,
"question": "Any accidents on site today?",
"question.id": 1097329,
"question.tag": 0,
"images": [],
"videos": []
},
调查类:
public class survey
{
public string id { get; set; }
public Nullable<bool> trueFalse { get; set; }
public string question { get; set; }
public string question.id { get; set; } //error in writing the question id attribute
public string desc { get; set; }
//public bool trueFalse { get; set; }
public string FormattedAnswer
{
get
{
if (trueFalse == null) return "NA";
return trueFalse == true ? "YES" : "NO";
}
}
}
完美!!!!!!!感谢您的解释。 – Rck7