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