4
votes

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":[]}]

What am I doing wrong?

2
Can you edit your question and include the correct string that you're trying to parse? The one you included is missing ending double quote. - Gaurav Mantri
Is it better now? - Boris Lipschitz
What's wrong with a JSON array here? Why reinvent the wheel? - Graham

2 Answers

3
votes

I can repro the issue with Newtonsoft.Json version 10+. If downgrade is possible, please have a try to use Newtonsoft.Json version 9.0.1. Then it works correctly on my side. We also could rasie an issue to Azure function team.

2
votes

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.

We're improving the Visual Studio experience so that it's clear that there's a strict upper bound on the dependency.