我是 .net 核心编程的新手。
我在如何格式化我的 Json 对象时遇到问题。我想创建一个 Json 对象,并且该 JSON 的字段之一将处理一个 Json 对象。
我正在使用 MVC 架构。谢谢
这是我的代码。
public async Task<List<Schedule>> getAllScheds(){
dynamic response = new JObject();
try {
var data = await _context.MlfbSchedules
.Include(h => h.Team1)
.Include(a => a.Team2)
.Include(s => s.StadiumID)
.ToListAsync();
return data;
} catch (Exception e) {
response.Error = e.ToString();
return response;
}
}
此函数正在返回此数据。
[
{
"scheduleId": 43,
"team1": {
"teamId": 1,
"city": "Virginia",
"teamName": "Armada",
"sImage": "/images/teams-logo-small/virginia.png",
"image": "/images/teams-logo/virginia.png",
"helmetImage": "/images/teams-helmet/virginia.png",
"createdBy": null,
"createdDate": "2016-06-22T10:03:35.58",
"modifiedBy": null,
"modifiedDate": null,
"isDeleted": null
},
"team2": {
"teamId": 3,
"city": "Florida",
"teamName": "Fusion",
"sImage": "/images/teams-logo-small/florida.png",
"image": "/images/teams-logo/florida.png",
"helmetImage": "/images/teams-helmet/florida.png",
"createdBy": null,
"createdDate": "2016-06-22T10:03:35.58",
"modifiedBy": null,
"modifiedDate": null,
"isDeleted": null
},
慕丝7291255
相关分类