从 Azure Functions HttpTrigger 返回 JArray 的问题 [英] Issue with returning JArray from Azure Functions HttpTrigger
问题描述
我正在尝试从 HttpTrigger 类型的 Azure 函数返回 JArray 对象:
I'm trying to return JArray object from Azure Function of HttpTrigger type:
JArray a = JArray.Parse("[{"reportId": "1111","reportName": "AAAA"}]");
return req.CreateResponse(HttpStatusCode.OK, a);
但是,由于某种原因,响应正文返回为:
However, for some reason, the response body returned as:
[{"reportId":[],"reportName":[]}]
我做错了什么?
推荐答案
Azure Functions 要求您使用 Newtonsoft.Json 版本 9.0.1,因为我们不支持绑定重定向.您的代码与 Functions 主机在同一进程中运行,这意味着您具有相同的绑定重定向.
Azure Functions requires that you use Newtonsoft.Json version 9.0.1, as we don't support binding redirects. Your code is running in the same process as the Functions host, which means you have the same binding redirects.
我们正在改进 Visual Studio 体验,以便清楚地看出依赖项有严格的上限.
We're improving the Visual Studio experience so that it's clear that there's a strict upper bound on the dependency.
这篇关于从 Azure Functions HttpTrigger 返回 JArray 的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!