Q:

Return an F# record type as JSON in Azure Functions

I'm creating a simple azure function in F#. At the end, I'm returning a record type as JSON. I'm doing something like this:
let y = {Gender = "Woman"; Frequency = 17; Percentage = 100.0}
req.CreateResponse(HttpStatusCode.OK, y);

When I call the function from Postman I'm getting this JSON
{"Gender@":"Woman","Frequency@":17,"Percentage@":100}
It looks like that this is caused by the default serializer (Serializing F# Record type to JSON includes '@' character after each property).
Then I tried to use Newtonsoft.Json. Now, the code looks like this:
req.CreateResponse(HttpStatusCode.OK, JsonConvert.SerializeObject(y));

But now I'm getting this using postman:
"{\"Gender\":\"Woman\",\"Frequency\":17,\"Percentage\":100}"

I'd like to get this response:
{"Gender":"Woman","Frequency":17,"Percentage":100}
How can I get this JSON response? Is there any other way apart from specifying DataMemberAttribute?
Thanks

A:

I don't think you can use JSON.Net (would be nice) because the AzureFunctions infrastructure seems to the Data Contract Serializers 
I have just implemented the fix as per Serializing F# Record type to JSON includes '@' character after each property and it works for me if a bit clunkier than you may hope. 
I was also struggling to fix this and you got me going in the right direction - Thanks
#r "System.Runtime.Serialization"

open System.Runtime.Serialization

[<DataContract>]
type SearchItem = {
    [<field: DataMember(Name="Gender")>]
    Gender: string
    [<field: DataMember(Name="Frequency")>]
    Frequency: int
    [<field: DataMember(Name="Percentage")>]
    Percentage: float
} 

