I have a set of HttpTrigger Azure Functions in dotnet5 and I want to return JSON from those Azure Functions. I'm using return new OkObjectResult(myObject)
but that is not providing JSON but rather the JSON is in the "Value" element of the JSON returned
i.e. the results look a bit like
{
"Value": {
"MyValueOne": true,
"MyValueTwo": 8
},
"Formatters": [],
"ContentTypes": [],
"DeclaredType": null,
"StatusCode": 200
}
as opposed to the expected
{
"MyValueOne": true,
"MyValueTwo": 8
}
I've gone down a couple paths with different return objects, but they always seem to be having these extra values and the JSON I want returned usually wrapped up in a Value or Content with in other JSON, for example: JsonResult(myObject) OR ContentResult() { Content = serialisedVersionOfMyObject }
I even tried the HttpResponseMessage path; but ran into trouble with the HttpTrigger and expected return of Tast
I feel like I'm missing something simple; what is the expected / desired / straight-forward way of returning "just json" from an Azure Function?