Forum Discussion
Copy Activity - JSON Mapping
Hello,
I have created a copy activity in Azure synapse Analytics.
I have a JSON file as an input and would like to unpack and save it as a csv file.
I have tried several times but can not get the data in the correct output.
The below is my input file:
{
"status": "success",
"requestTime": "2025-06-26 15:23:41",
"data": [
"Monday",
"Tuesday",
"Wednesday"
]
}
I would like to save it in the following output.
status | requestTime | Data |
success | 26/06/2025 15:23 | Monday |
success | 26/06/2025 15:23 | Tuesday |
success | 26/06/2025 15:23 | Wednesday |
I am struggling to configure the mapping section correctly. I can not understand how to unpack the data array.
The $['data'][0] gives me the first element.
I would like to extract all elements in the format above.
Any help would be appreciated.
2 Replies
- Arya1978Copper Contributor
Sample Pipeline JSON
{
"name": "FlattenJsonToCsv",
"properties": {
"activities": [
{
"name": "CopyFromJsonToCsv",
"type": "Copy",
"dependsOn": [],
"policy": {
"timeout": "7.00:00:00",
"retry": 0,
"retryIntervalInSeconds": 30,
"secureOutput": false,
"secureInput": false
},
"typeProperties": {
"source": {
"type": "JsonSource",
"storeSettings": {
"type": "AzureBlobStorageReadSettings"
},
"formatSettings": {
"type": "JsonReadSettings"
},
"collectionReference": "$.data"
},
"sink": {
"type": "DelimitedTextSink",
"storeSettings": {
"type": "AzureBlobStorageWriteSettings"
},
"formatSettings": {
"type": "DelimitedTextWriteSettings",
"columnDelimiter": ",",
"quoteAllText": true
}
},
"enableStaging": false,
"translator": {
"type": "TabularTranslator",
"mappings": [
{
"source": {
"path": "$.status"
},
"sink": {
"name": "status"
}
},
{
"source": {
"path": "$.requestTime"
},
"sink": {
"name": "requestTime"
}
},
{
"source": {
"path": "@item()"
},
"sink": {
"name": "Data"
}
}
]
}
},
"inputs": [
{
"referenceName": "JsonSourceDataset",
"type": "DatasetReference"
}
],
"outputs": [
{
"referenceName": "CsvSinkDataset",
"type": "DatasetReference"
}
]
}
]
}
} - Arya1978Copper Contributor
1. Set Up Source Dataset (JSON)
• Dataset type: JSON
• File pattern: Single JSON file
• Import Schema: No
• JSON Path: Leave blank (or just point to $.data if needed to preview array)
2. Enable Unroll Feature in Source
In the Copy Activity > Source tab:
• Collection reference: $.data
• This tells ADF to "flatten" the array items and treat each item as a row.
3. Configure Mappings
Go to Mapping tab in the Copy Activity. You’ll map:
Source Path Target Column
$.status status
$.requestTime requestTime
@item() Data@item() refers to each element inside the data array being unrolled.
________________________________________
4. Output Format (CSV)
• Sink type: Delimited Text (CSV)
• Make sure the sink has columns: status, requestTime, Data
• Choose appropriate column delimiter (e.g., comma)
• If you want to format the date, you may post-process with Data Flow or Logic App (ADF Copy Activity doesn’t support date formatting directly).