You need to create the custom activity
Note : this is sample file you need to change as per your need
C# code for creating a JSON array with dynamic values and assigning it to a JSON object:
using Newtonsoft.Json;
public class Subsidy { public string ID { get; set; } public string Name { get; set; } }
JArray defaultRefArray = new JArray();
List<Dictionary<string, string>> dataList = // Your dynamic data source
foreach (var item in dataList)
{
JObject subsidyObject = new JObject(new JProperty("ID", item["ID"]), new JProperty("Name", item["Name"]));
JObject mainObject = new JObject(new JProperty("Type", item["Type"]), new JProperty("Subsidy", subsidyObject));
defaultRefArray.Add(mainObject);
}
JObject finalObject = new JObject(new JProperty("defaultref", defaultRefArray));
string jsonString = JsonConvert.SerializeObject(finalObject);
This code achieves the same functionality but removes unnecessary explanations. You can integrate this code into your UiPath workflow using an “Assign” activity as described previously.