convert json in parse inputs azure function code example

Example: convert json in parse inputs azure function

#r "Newtonsoft.Json"

using System.Net;
using Newtonsoft.Json;

public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)
{
    dynamic body = await req.Content.ReadAsStringAsync();
    var e = JsonConvert.DeserializeObject<EventData>(body as string);
    return req.CreateResponse(HttpStatusCode.OK, JsonConvert.SerializeObject(e));
}

public class EventData
{
    public string Category { get; set; }
    public string Action { get; set; }
    public string Label { get; set; }
}

Tags:

Misc Example