Share via

JSON Processing in ADF - Copy Activity

Biju Mathew 386 Reputation points
2023-05-12T12:51:53.8066667+00:00

Hey

Please i need some help here.

we have an ADF pipeline with a Copy Activity.

The source is a rest api which returns a JSON response.

The sink is a blob connector of type json.

I tested the rest api independently and the rest api returns a response like below:


{"result":[{"level":"1","source":"Remote Process Sync","created":"2023-05-10 02:51:59","created_by":"system","application":null},
           {"level":"1","source":"Remote Process Sync","created":"2023-05-10 02:59:00","created_by":"system","application":null}]
		   }

BUt after running the pipeline and i look at the output json file in the blob container, it looks like this :

[
{"result":[{"level":"1","source":"Remote Process Sync","created":"2023-05-10 02:51:59","created_by":"system","application":null},
           {"level":"1","source":"Remote Process Sync","created":"2023-05-10 02:59:00","created_by":"system","application":null}]
		   }
]

If you noticed, It appears like the SINK Blob connector of type JSON encloses the api response in [ ]

I have 2 requirements( I am fine with building 2 different pipelines for these 2 requirements)

  1. I need to get the json blob file exactly like the api response i.e. without the outer [ ]
  2. I need to get the json blob file from the result array in the api response . see below
[{"level":"1","source":"Remote Process Sync","created":"2023-05-10 02:51:59","created_by":"system","application":null},
           {"level":"1","source":"Remote Process Sync","created":"2023-05-10 02:59:00","created_by":"system","application":null}]

Please let me know if either or both are possible in ADF.

Azure Data Factory
Azure Data Factory

An Azure service for ingesting, preparing, and transforming data at scale.


1 answer

Sort by: Most helpful
  1. Sedat SALMAN 14,455 Reputation points MVP
    2023-05-13T17:53:09.93+00:00

    for requirement 1

    you can use flatten transformation as in the link

    https://learn.microsoft.com/en-us/azure/data-factory/data-flow-flatten

    for requirement 2

    Add a mapping between the 'result' array in the source JSON and the target JSON sink.

    https://learn.microsoft.com/en-us/azure/data-factory/concepts-data-flow-overview

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.