Inside the Azure function my input is ServiceBus queue properties
Code is to retrieve that all properties are -
using System.Net;
using Newtonsoft.Json;
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)
{
string jsonContent = await req.Content.ReadAsStringAsync();
return req.CreateResponse(HttpStatusCode.OK,jsonContent);
}
Output is -
[
"{\"DeliveryCount\":\"1\",\MessageId\":\"bac52de2d23a487a9ed388f7313d93e5\"}"
]
I want to add one more property into this json object , how can I add it here in azure function so that I can return modified object like below -
[
"{\"DeliveryCount\":\"1\",\MessageId\":\"bac52de2d23a487a9ed388f7313d93e5\",\"MyProperty\":\"TEST\"}"
]
dynamic. Doesn't have to be a concrete type.dynamic x = JsonConvert.DeserializeObject<dynamic>(jsonContent);I would have thought. Then you can add a new property, and serialize it back again before returning it.x.NewProperty = "y". That's the whole point aboutdynamic, it's, well...dynamic.