【发布时间】:2021-11-28 23:04:08
【问题描述】:
我想解析 JSON 正文并在 C# 中以 HttpPost 方法返回内容。
JSON 正文包含以下信息:
{
"name": "John",
"age": "20"
}
[HttpPost]
public async Task<IActionResult> Test()
{
return new JsonResult(new { items = new string[] { name, age } });
}
我希望方法返回:
John 20
【问题讨论】:
-
要确认 JSON 已发布到您的
Test()操作,您需要知道如何从中获取name和age变量? -
@toneo 是的,这是正确的
标签: c# json .net-core http-post webapi