how to convert csv to a nested json format with dynamic columns?

Praveen S 5 Reputation points
2023-02-08T12:55:58.1333333+00:00

I am trying to convert a csv file into a nested json file. so I created a data flow, and used derived column to create a new nested column with sub columns as shown in image. now what I am trying to do is that instead of mapping each column manually, it needs to automatically map each column based on condition eg: nesting all columns that are not listed in a array variable, these columns are nested in one column

expected result:


{
  other_cols:"sgarg",
  nested_col:{
    col1 : col1val,
    col2 : col2val,
    col3 : col3val
  }
}

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,625 questions
{count} votes

1 answer

Sort by: Most helpful
  1. AnnuKumari-MSFT 34,556 Reputation points Microsoft Employee Moderator
    2023-02-15T10:20:44.92+00:00

    Hi Praveen S ,

    Apologies for delay in response. Unfortunately, it's not possible to create nested JSON if your source schema is not defined and not constant. I tried to check if Column patterns in derived column and aggregate could be helpful , but in your case it wont be since schema is not defined. You need to write your own code in C# or python using custom function to achieve that.


    Hope it helps. Please accept the answer if it was helpful. Thanks .

    0 comments No comments

Your answer

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