JSON嵌套数据与MVC

JSON嵌套数据与MVC,json,asp.net-mvc,Json,Asp.net Mvc,提前谢谢你的帮助。我已经搜索了几个小时,还没有找到这个看似简单问题的答案。我仍然是MVC和SO的新手,请善待我 我从以前的开发人员那里继承了这个项目,愚蠢地认为这很容易,但事实证明很难 我正在从一个API迁移到另一个API,到目前为止,大多数模型更改都进行得非常顺利。不幸的是,我用这个撞到了墙 以下是JSON响应的一个示例: { "attendeeid":"123456789", "registrationstatus":"Confirmed", "testregistr

提前谢谢你的帮助。我已经搜索了几个小时,还没有找到这个看似简单问题的答案。我仍然是MVC和SO的新手,请善待我

我从以前的开发人员那里继承了这个项目,愚蠢地认为这很容易,但事实证明很难

我正在从一个API迁移到另一个API,到目前为止,大多数模型更改都进行得非常顺利。不幸的是,我用这个撞到了墙

以下是JSON响应的一个示例:

{
    "attendeeid":"123456789",
    "registrationstatus":"Confirmed",
    "testregistration":"1",

    "category":{
        "categoryid":"987654321",
        "name":"MERIT"
},

"subcategory":"",
"approvalstatus":"",
"discountcode":"",
"individualcost":"0.00",
"groupcount":2,
"cost":"0.00",
"totalcost":"0.00",
"received":"0.00",
"imiscontactid":null,
"recordid":"0cH+Z7x8gZLzORzXej39Ew==",
"responses":
[
    {
        "questionid":"12211221",
        "fieldname":"email",
        "name":"Email Address",
        "pageid":"1",
        "page":"Welcome",
        "choicekey":"jdoe@website.com",
        "response":"jdoe@website.com"
    },
    {
        "questionid":"12211221",
        "fieldname":"97531",
        "name":"Please indicate the years you have been a winner?",
        "pageid":"2",
        "page":"Attendee Information",
        "choicekey":"","response":["2012","2010","2009"]
    }
],
"created":"2015-07-27 11:45:31",
"language":"eng",
"tax":"0.00",
"statetax":"0.00",
"categorycost":"0.00",
"subcategorycost":"0.00",
"agendacost":"0.00",
"optioncost":"0.00",
"hotelcost":"0.00",
"guestcost":"0.00",
"adjustments":"0.00",
"lastmodified":"2015-08-07 11:15:40",
"checkindate":"",
"invoicelink":"https:\/\/www.website.com\/ereg\/pdfinvoice.php?id=0afer%suku7%31337%4779%82%3d"
}
注意嵌套

这是我的模型:

    public class Respons {
        [Key]
        [Column("QuestionID")]
        public string questionid { get; set; }

        public string EventID { get { return Controllers.RequestQueueController.GetEventID(); } set { } }

        public int AttendeeID { get { return int.Parse(Controllers.RequestQueueController.GetAttID()); } set { } }

        [Column("QuestionText")]
        public string name { get; set; }

        [Column("AnswerText")]
        public object response { get; set; }
    }

    public class Answer {
        public string AnswerID { get { return attendeeid + "-" + EventID + responses[0].questionid; } set { } }

        public string EventID { get { return Controllers.RequestQueueController.GetEventID(); } set { } }

        [Column("AttendeeID")]
        public int attendeeid { get; set; }

        public List<Respons> responses { get; set; }

        [Column("AnsweredDate")]
        public string created { get; set; }

        [Column("ModifiedDate")]
        public string lastmodified { get; set; }
    }
控制器:

foreach(var answer in answers){
    answer.AnswerID = answer.AnswerID.Replace(":fill:", answer.responses[i].questionid);
}

对不起,你的问题不清楚。如果我猜对了,你已经知道了!对不起,你的问题不清楚。如果我猜对了,你已经知道了!
foreach(var answer in answers){
    answer.AnswerID = answer.AnswerID.Replace(":fill:", answer.responses[i].questionid);
}