© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
12 replies
malkav

Making an azure Function to merge two JSON objects

I'm trying to make an Azure Function to merge two JSON objects, but apparently azure Functions don't like the idea of adding a JSON like this:
{ "main_object": "{ \"name\": \"some name\", \"more_properties\": \"values\" }" }
{ "main_object": "{ \"name\": \"some name\", \"more_properties\": \"values\" }" }

so now I'm trying to figure out how to make sure I can pass two json objects of which I not know their data into the request body.
My parameters on the request body should be
(JSON)main_object
(JSON)main_object
,
(JSON)secondary_object
(JSON)secondary_object
,
(anything, so JToken??)matching_property
(anything, so JToken??)matching_property
,
(string[])merge_properties
(string[])merge_properties


Does this mean I should be using
JToken
JToken
?
currently I'm trying this:
[FunctionName("MergeSingleAsync")]
public static async Task<IActionResult> RunAsync(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = null)]
HttpRequest req, ILogger log)
{
  string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
  Inputs data = JsonConvert.DeserializeObject<Inputs>(requestBody);
  // ...
}

class Inputs
{
  [JsonProperty("main_object")] public string MainObject {get;set;} // Should be JToken??
  [JsonProperty("secondary_object")] public string SecondaryObject {get;set;} // Should be JToken??
  [JsonProperty("matching_property")] public JToken MatchingProperty {get;set;}
  [JsonProperty("merge_properties")] public string[] MergeProperties {get;set;}
}
[FunctionName("MergeSingleAsync")]
public static async Task<IActionResult> RunAsync(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = null)]
HttpRequest req, ILogger log)
{
  string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
  Inputs data = JsonConvert.DeserializeObject<Inputs>(requestBody);
  // ...
}

class Inputs
{
  [JsonProperty("main_object")] public string MainObject {get;set;} // Should be JToken??
  [JsonProperty("secondary_object")] public string SecondaryObject {get;set;} // Should be JToken??
  [JsonProperty("matching_property")] public JToken MatchingProperty {get;set;}
  [JsonProperty("merge_properties")] public string[] MergeProperties {get;set;}
}

I would love some assistance 😅 I'm stuck at this for 2 days now
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ how to merge two objects?
C#CC# / help
2y ago
Merge objects game
C#CC# / help
2y ago
Merge two separate databases
C#CC# / help
3y ago