The response output from a JObject content is not well formed in an application.
Narrowing the problem to it's minimum possible size, there should be some missing detail that produce this behavior (very unlikely is other cause).
The following code shows a JSON payload to be the response from an API endpoint:
[HttpPost]
public async Task<ObjectResult> Post()
{
var json = JsonConvert.DeserializeObject<JObject>(
@"{""parameter-1"":""J234546ZrVl"",""value-2"":""3E9CY3gertertmdALWMmHkvP"",""test-3"":""verify please""}");
var result = new ObjectResult(json);
return result;
}
The response is received as:
{"parameter-1":[],"value-2":[],"test-3":[]}
And should be:
{"parameter-1":"J234546ZrVl","value-2":"3E9CY3gertertmdALWMmHkvP","test-3":"verify please"}
When debugging the variable json
is correct, and has all the property values, but somehow it is not rendered correctly.
Any ideas?
- This is using: ASP Net Core 5.0
- ObjectResult is defined in:
namespace Microsoft.AspNetCore.Mvc
- Its constructor is:
public ObjectResult(object value);
- And has the interfaces:
public class ObjectResult : ActionResult, IStatusCodeActionResult, IActionResult