By making a list with objects with Append Item to list acitvity like this:
JObject.FromObject(
New With {
key .status = “”},
New With {
key .order_task = “”},
New With {
key .process_date = today,
key .criteria = “<”},
New With {
key .process_type = “A”})
And then creating the array like this:
JObject.FromObject(
New With {
key .search = JArray.FromObject(list),
key .limit = “1”}).ToString
When I create the list, I get the following error: BC30516: Overload resolution failed because no accessible ‘FromObject’ accepts this number of arguments.
But I want the json object to be inside the “search” array" and “limit” object outside the array. How can I do this to get it on the format i want with dictionary then like this:
Please refer the below workflow which would help you solve the problem in creating array of JSON objects.
Each dictionary(String, Object) will result in one JSON object. If you want to have array of JSON, then make a list of dictionaries and assign it to another dictionary.
You can also use the below snippet to build your JSON using Invoke code
Try
'Inner fields
Dim statusJson As JObject = New JObject()
statusJson.Add("status","")
Dim order_task As JObject = New JObject()
order_task.Add("order_task","")
Dim process_date As JObject = New JObject()
process_date.Add("process_date","")
process_date.Add("criteria","<")
Dim process_type As JObject = New JObject()
process_type.Add("process_type","")
'add fields to Json array
Dim searchJsonArray As JArray = New JArray()
searchJsonArray.Add(statusJson)
searchJsonArray.Add(order_task)
searchJsonArray.Add(process_date)
searchJsonArray.Add(process_type)
'building final json from the array and adding limit field
Dim FinalJson As JObject = New JObject()
FinalJson .Add("Search",searchJsonArray)
FinalJson .Add("limit","1")
Console.WriteLine(FinalJson.ToString)
Catch exc As Exception
Console.WriteLine(exc.Message)
End Try
The first method creating a dictionary worked as I wanted. I am not so familiar with the invoke code acitvity. How would I be able to generate the json body to use in a http request activity from the code?