Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
Neka
Helper III
Helper III

How to create an array from specific JSON key values for ForEach activity.

Hello,

I have a JSON file with this structure from a CopyData activity step in my Data Factory pipeline: 

"value": [{
"id": "123",
"isReadOnly": false,
//additional key-values
}, {
"id": "1234",
"isReadOnly": false,
//additional key-values
}, {
"id": "12345",
"isReadOnly": false,
//additional key-values
},

 

I want to extract all the 'ids' and turn them into an array so that I can iterate over them in a ForEach activity in Data Factory ex. ["123","1234","12345"]. How do I accomplish this? 

 

I am very new to Data Factory so thank you for any other suggestions regarding using the ForEach to iterate over all the ids. As well, if you are able, the more detail the better. Thank you!

1 ACCEPTED SOLUTION
NandanHegde
Super User
Super User

Hey,

The output Value is by default an Array.

You can iterate over the Copy activity output directly via For each and get the ID details per iteration itself.

 

NandanHegde_0-1709004375168.png

where parameter Test value is :

[{ "id": "123", "isReadOnly": false }, { "id": "1234", "isReadOnly": false }]

 

You can use For each activity to iterate over the value directly 

NandanHegde_1-1709004440808.png

within for each, use Set variable activity to get the ID value 

 

NandanHegde_2-1709004480064.png

Output :

NandanHegde_3-1709004515730.png

 




----------------------------------------------------------------------------------------------
Nandan Hegde (MSFT Data MVP)
LinkedIn Profile : www.linkedin.com/in/nandan-hegde-4a195a66
GitHUB Profile : https://github.com/NandanHegde15
Twitter Profile : @nandan_hegde15
MSFT MVP Profile : https://mvp.microsoft.com/en-US/MVP/profile/8977819f-95fb-ed11-8f6d-000d3a560942
Topmate : https://topmate.io/nandan_hegde
Blog :https://datasharkx.wordpress.com

View solution in original post

3 REPLIES 3
NandanHegde
Super User
Super User

Hey,

The Parameter is just an example for demonstration purpose.

If the file size is less, you can use lookup activity to read the file and use that lokup value inplace of parameter




----------------------------------------------------------------------------------------------
Nandan Hegde (MSFT Data MVP)
LinkedIn Profile : www.linkedin.com/in/nandan-hegde-4a195a66
GitHUB Profile : https://github.com/NandanHegde15
Twitter Profile : @nandan_hegde15
MSFT MVP Profile : https://mvp.microsoft.com/en-US/MVP/profile/8977819f-95fb-ed11-8f6d-000d3a560942
Topmate : https://topmate.io/nandan_hegde
Blog :https://datasharkx.wordpress.com
NandanHegde
Super User
Super User

Hey,

The output Value is by default an Array.

You can iterate over the Copy activity output directly via For each and get the ID details per iteration itself.

 

NandanHegde_0-1709004375168.png

where parameter Test value is :

[{ "id": "123", "isReadOnly": false }, { "id": "1234", "isReadOnly": false }]

 

You can use For each activity to iterate over the value directly 

NandanHegde_1-1709004440808.png

within for each, use Set variable activity to get the ID value 

 

NandanHegde_2-1709004480064.png

Output :

NandanHegde_3-1709004515730.png

 




----------------------------------------------------------------------------------------------
Nandan Hegde (MSFT Data MVP)
LinkedIn Profile : www.linkedin.com/in/nandan-hegde-4a195a66
GitHUB Profile : https://github.com/NandanHegde15
Twitter Profile : @nandan_hegde15
MSFT MVP Profile : https://mvp.microsoft.com/en-US/MVP/profile/8977819f-95fb-ed11-8f6d-000d3a560942
Topmate : https://topmate.io/nandan_hegde
Blog :https://datasharkx.wordpress.com

Thank you for answering my question, but how do I make the Default Value in the Parameters my Id key from my JSON file? In your example, it looks like the JSON file has been copy pasted into default value but since I'm creating a new JSON file everytime I run copy data, how would I make sure that that new JSON file is always used? 

Helpful resources

Announcements
April Fabric Update Carousel

Fabric Monthly Update - April 2026

Check out the April 2026 Fabric update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Top Solution Authors