将Json字符串转换为C#对象列表

8 浏览
0 Comments

将Json字符串转换为C#对象列表

我想将一个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字符串

"[

{

"Question": {

"QuestionId": 49,

"QuestionText": "你叫什么名字?",

"TypeId": 1,

"TypeName": "多项选择",

"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"

},

{

"Question": {

"QuestionId": 51,

"QuestionText": "你聪明吗?",

"TypeId": 3,

"TypeName": "是非题",

"Model": {

"options": [

{

"text": "是",

"selectedMarks": "7"

},

{

"text": "否",

"selectedMarks": "0"

}

],

"maxOptions": 10,

"minOptions": 0,

"isAnswerRequired": false,

"selectedOption": "3",

"answerText": "",

"isRangeType": false,

"from": "",

"to": "",

"mins": "01",

"secs": "04"

}

},

"CheckType": "",

"S1": "",

"S2": "",

"S3": "",

"S4": "",

"S5": "",

"S6": "",

"S7": "是",

"S8": "",

"S9": "",

"S10": "",

"ScoreIfNoMatch": "2"

}

]"

0