Wanted to pick your brains on something So, in Azure data factory, I am running a set of activities which at the end of the run produce a json segment
{"name":"myName", "email":"email@somewhere.com", .. <more elements> }
This set of activities occurs in a loop - Loop Until activity. My goal is to have a final JSON object like this:
"profiles":[
{"name":"myName", "email":"email@somewhere.com", .. <more elements> },
{"name":"myName", "email":"email@somewhere.com", .. <more elements> },
{"name":"myName", "email":"email@somewhere.com", .. <more elements> },
...
{"name":"myName", "email":"email@somewhere.com", .. <more elements> }
]
That is a concatenation of all the individual ones.
To put in perspective, each individual item is a paged data from a rest api - and all them constitute the final response. I have no control over how many are there.
I understand how to concatenate individual items using 2 variables
jsonTemp = @concat(finalJson, individualResponse)
finalJson = jsonTemp
But, I do not know how to make it all under the single roof "profiles" afterwards.
Found the solution by using the union
function.
basically, outside of the forEach loop, I created an array variable varComplete
and then inside the loop after each call to a web activity, I set another variable varTempResponse
as
@union( activity('Web1').output, varComplete)
Then, I reset the varComplete
to the value of varTempResponse
.
varComplete = varTempResponse