我正在研究 ASP.net MVC Applciation
我在准备 json 响应以从控制器操作方法返回时遇到困难。
我需要这样的东西:
{
"cityMap": {"11": "Chennai", "12": "Mumbai", "13": "Delhi"},
"rows": [
{ "SID": "1", "SNAME": "ABC", "CITY": "11" },
{ "SID": "2", "SNAME": "XYZ", "CITY": "12" },
{ "SID": "3", "SNAME": "ACX", "CITY": "13" },
{ "SID": "4", "SNAME": "KHG", "CITY": "13" },
{ "SID": "5", "SNAME": "ADF", "CITY": "12" },
{ "SID": "6", "SNAME": "KKR", "CITY": "11" }
]
}
我在sortedlist
名称 slLocations中有 cityMap 值
我有列表 liStudents 形式的行值
我使用以下语法发送 json 响应:
return JSON(new { rows=liStudents},jsonRequestBehaviour.AllowGet)
通过使用上述语法,我得到这样的 json 响应:
{
"rows": [
{ "SID": "1", "SNAME": "ABC", "CITY": "11" },
{ "SID": "2", "SNAME": "XYZ", "CITY": "12" },
{ "SID": "3", "SNAME": "ACX", "CITY": "13" },
{ "SID": "4", "SNAME": "KHG", "CITY": "13" },
{ "SID": "5", "SNAME": "ADF", "CITY": "12" },
{ "SID": "6", "SNAME": "KKR", "CITY": "11" }
]
}
请帮助如何使用 liStudents 和 liLocations 扩展 json 响应