public static class MergeSingleAsync
{
[FunctionName("MergeSingleAsync")]
public static async Task<IActionResult> RunAsync(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]
HttpRequest req, ILogger log)
{
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(requestBody);
Dictionary<string, dynamic> mainObject =
JsonConvert.DeserializeObject<Dictionary<string, dynamic>>(data["main_object"]);
Dictionary<string, dynamic> secondaryObject =
JsonConvert.DeserializeObject<Dictionary<string, dynamic>>(data["secondary_object"]);
dynamic matching = data["matching_property"];
string[] mergingProperties = data["merge_properties"] == null
? Array.Empty<string>()
: (string[])JsonConvert.DeserializeObject<string[]>(data.merge_properties);
if (!mainObject.ContainsKey(matching) && !secondaryObject.ContainsKey(matching) &&
mainObject[matching] != secondaryObject[matching])
throw new($"The matching property: {matching} did not match in both objects provided to the function");
return mergingProperties.Length == 0
? MergeAll(mainObject, secondaryObject)
: MergeSpecific(mainObject, secondaryObject, mergingProperties);
}
public static class MergeSingleAsync
{
[FunctionName("MergeSingleAsync")]
public static async Task<IActionResult> RunAsync(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]
HttpRequest req, ILogger log)
{
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(requestBody);
Dictionary<string, dynamic> mainObject =
JsonConvert.DeserializeObject<Dictionary<string, dynamic>>(data["main_object"]);
Dictionary<string, dynamic> secondaryObject =
JsonConvert.DeserializeObject<Dictionary<string, dynamic>>(data["secondary_object"]);
dynamic matching = data["matching_property"];
string[] mergingProperties = data["merge_properties"] == null
? Array.Empty<string>()
: (string[])JsonConvert.DeserializeObject<string[]>(data.merge_properties);
if (!mainObject.ContainsKey(matching) && !secondaryObject.ContainsKey(matching) &&
mainObject[matching] != secondaryObject[matching])
throw new($"The matching property: {matching} did not match in both objects provided to the function");
return mergingProperties.Length == 0
? MergeAll(mainObject, secondaryObject)
: MergeSpecific(mainObject, secondaryObject, mergingProperties);
}