I am creating a simple azure function in F #. At the end, I return the record type as JSON. I am doing something like this:
let y = {Gender = "Woman"; Frequency = 17; Percentage = 100.0}
req.CreateResponse(HttpStatusCode.OK, y);
When I call a function from Postman, I get this JSON
{"Gender@":"Woman","Frequency@":17,"Percentage@":100}
This seems to be caused by the default serializer ( F # record type serialization for JSON includes the "@" character after each property ).
Then I tried using Newtonsoft.Json. Now the code is as follows:
req.CreateResponse(HttpStatusCode.OK, JsonConvert.SerializeObject(y));
But now I get this using the postman:
"{\"Gender\":\"Woman\",\"Frequency\":17,\"Percentage\":100}"
I want to get this answer:
{"Gender":"Woman","Frequency":17,"Percentage":100}
How can I get a JSON response? Is there any other way besides the indication DataMemberAttribute?
thank
source
share