Reputation: 209
I want to loop over the json key value pairs in Azure Data Factory and transform it to array (or ultimately a string). Here is my sample variable:
{"Key1": "val1", "key2": "val2"}
What I want to achieve is an array, which looks like below:
["Key1=val1", "key2=val2"]
Keys and values are dynamic, number of keys and their names may change.
What's the best way to achieve this? I can't find any functionality that would allow me to loop over the key-value pairs.
Upvotes: 0
Views: 59
Reputation: 11454
As all the values are simple key value pairs, after lookup activity, you can use below approach to achieve your requirement.
For sample, I took the below object in an object type parameter in pipeline.
{"Key1":"val1","key2":"val2","key3":"val3"}
Create an array variable in the pipeline variables section and use the below expression for that variable in a set variable activity.
@split(replace(replace(replace(replace(string(pipeline().parameters.object),'"',''),':','='),'{',''),'}',''),',')
Replace the parameter object with your object from lookup activity expression.
It will give the expected output upon debugging the pipeline.
Upvotes: 0