Convert Json objets to array using Azure data flow

youssef125 266 Reputation points
2021-10-23T18:30:21.857+00:00

I'm using azure data flow, and I'm using Union to combine two sources, so this union contains JSON documents. is there a way to convert this json document to array of documents:
Union contains :

{"key":1,"value":"test8"}
{"key":2,"value":"test6"}
{"key":3,"value":"test3"}

what I'm looking for is a way to get like this format :

[
 {
   "key": 1,
   "value": "test8"
 },
{
 "key": 2,
 "value": "test6"
},
{
 "key": 3,
 "value": "test3"
}
]

Thanks for you help

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
9,528 questions
0 comments No comments
{count} votes

Accepted answer
  1. svijay-MSFT 5,201 Reputation points Microsoft Employee
    2021-10-25T14:28:51.683+00:00

    Hello @youssef125 ,

    Welcome to the Microsoft Q&A platform.

    Unfortunately, there was not direct approach to achieve the above requirement.

    I came up with two possible options

    Option 1 :

    You can create a collection using the Aggregates Schema Modifier.

    143495-image.png

    Create a column without any Group and add the below expression.

    143512-image.png

    Output :

    143440-image.png

    However, there is an additional key created in the name of the aggregate column provided.

    Option 2 :

    I outputted the Data flow file to a blob storage and invoked the Copy Activity with the output of the data flow as a source.

    I set the sink settings of the Copy Activity to File pattern as Array of Objects

    143485-image.png

    Output

    143531-image.png

    Hope this will help. Please let us know if any further queries.

    ------------------------------

    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
    • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators
    0 comments No comments

0 additional answers

Sort by: Most helpful