I am new to angularjs and ASP.NET webapi. I am working on some requirement which my base tables are as below
CurriculumID SubjectArea CourseNumber
------------ ----------- ------------
303 GHIJ 101
304 ABCD 102
305 MNPQ 103
306 WXYZ 104
lookupId lookupValue
-------- -----------
1 Very Useful
2 Somewhat Useful
3 Not Useful
4 Not Applicable
5 Elsewhere
I have created two model classes (course and lookup) for these tables. How can i genarate JSon data as below in the backed using webapi Controller method public HttpResponseMessage getData(...)
I need the resultant JSON data like as below
$scope.questions = [
{
"CurriculumID": "303", "SubjectArea": "GHIJ", "CourseNumber": "101", "answers": [
{ "lookupValue": "Very Useful","lookupId":"1" },
{ "lookupValue": "Somewhat Useful", "lookupId": "2" },
{ "lookupValue": "Not Useful", "lookupId": "3" },
{ "lookupValue": "Not Applicable", "lookupId": "4" },
{ "lookupValue": "Elsewhere", "lookupId": "5" }
]
},
{
"CurriculumID": "304", "SubjectArea": "ABCD", "CourseNumber": "102", "answers": [
{ "lookupValue": "Very Useful","lookupId":"1" },
{ "lookupValue": "Somewhat Useful", "lookupId": "2" },
{ "lookupValue": "Not Useful", "lookupId": "3" },
{ "lookupValue": "Not Applicable", "lookupId": "4" },
{ "lookupValue": "Elsewhere", "lookupId": "5" }
]
}
.
.
.
];
Please look into the this link for better understanding https://plnkr.co/edit/73oA3rsrre8gqYX9V25W?p=preview
So how can write the two methods getData(to generate JSon data). please can anyone help me to serialize this structure in ASP.NET