我想将json字符串转换为对象列表。请帮我。如果由来完成,那会更有帮助NewtonJson。我试过了,但是没有用。我不想要该json的所有值。MatrixModel中提到的这是一个对象public class MatrixModel{
public string S1 { get; set; }
public string S2 { get; set; }
public string S3 { get; set; }
public string S4 { get; set; }
public string S5 { get; set; }
public string S6 { get; set; }
public string S7 { get; set; }
public string S8 { get; set; }
public string S9 { get; set; }
public string S10 { get; set; }
public int ScoreIfNoMatch { get; set; }}这是Json String "[
{
"Question": {
"QuestionId": 49,
"QuestionText": "Whats your name?",
"TypeId": 1,
"TypeName": "MCQ",
"Model": {
"options": [
{
"text": "Rahul",
"selectedMarks": "0"
},
{
"text": "Pratik",
"selectedMarks": "9"
},
{
"text": "Rohit",
"selectedMarks": "0"
}
],
"maxOptions": 10,
"minOptions": 0,
"isAnswerRequired": true,
"selectedOption": "1",
"answerText": "",
"isRangeType": false,
"from": "",
"to": "",
"mins": "02",
"secs": "04"
}
},
"CheckType": "",
"S1": "",
"S2": "",
"S3": "",
"S4": "",
"S5": "",
"S6": "",
"S7": "",
"S8": "",
"S9": "Pratik",
"S10": "",
"ScoreIfNoMatch": "2"
},
3 回答
白衣染霜花
TA贡献1796条经验 获得超10个赞
public static class Helper{ public static string AsJsonList<T>(List<T> tt) { return new JavaScriptSerializer().Serialize(tt); } public static string AsJson<T>(T t) { return new JavaScriptSerializer().Serialize(t); } public static List<T> AsObjectList<T>(string tt) { return new JavaScriptSerializer().Deserialize<List<T>>(tt); } public static T AsObject<T>(string t) { return new JavaScriptSerializer().Deserialize<T>(t); }}
添加回答
举报
0/150
提交
取消