【发布时间】:2021-11-26 16:52:01
【问题描述】:
我使用 HttpClient 来使用 API,然后我从 response.Content.ReadAsStringAsync().Result 中获取作为序列化字符串的响应,如下所述,
"{\r\n \"responseCode\": 400,\r\n \"errors\": [\r\n {\r\n \"errorCode\": \"RPM400\",\r\n \"errorMessage\": \"A program already exists.\"\r\n }\r\n ]\r\n}"
我想将其反序列化为
{
"responseCode": 400,
"errors": [
{
"errorCode": "RPM400",
"errorMessage": "A program already exists."
}
]
}
然后我必须将它发送到 UI,ASP.Net MVC 5 ActionMethod 中的返回类型是 ActionResult。
我尝试过使用 Json(JObject.Parse(response)) 和 Json(JToken.Parse(response)),但我在邮递员中得到如下的空响应
[
[
[]
],
[
[
[
[
[]
],
[
[]
]
]
]
]
]
同样的 Json(JObject.Parse(response)) 正在另一个应用程序 ASP.Net Core 2 中工作。您能提供一些帮助吗?
【问题讨论】:
-
是的@NoahBoegli
标签: json asp.net-mvc-5