LINQ to JSon response

2019-09-06 11:15发布

问题:

I have posted my class below and with sample data. I need to pass this class as an json response.

[Serializable]
public class Student
{
    public string Fname {get;set;}
    public string FirstSemMarkcsv {get;set;}  //This should hold marks as comma separated values.
    public string SecondSemMarkcsv {get;set;}  //This should hold marks as comma separated values.
}

Sample Data

Fname     FirstSemMark       SecondSemMark
John               95                  90
John               80                  93
John               70                  80
Peter              60                  78
Peter              80                  80
Peter              90                  85

I need to pass this as json response.

Any thoughts please.

Regards,

Ashish

回答1:

List<Student> students = GetStudentList();
return Json(students));