How to generate a JSON file in ADF from SQL table source based on a pre-defined JSON structure?

Robbin Berger 20 Reputation points
2023-03-27T13:28:51.7933333+00:00

Hi There,

I'm trying to create a JSON file based ofa pre-defined structure.

The source is a existing SQL Table in Azure.

To achieve this i've uploaded the json file to the datalake and created a 'dataset' to that file.

In a copy activity the mapping schema loads propperly and I can even map the fields as I need.

However when I run the activity an error occurs no matter what I try.

The unfortunate thing is that the error does not contain any message.

The JSON structure looks like below.
In which the 'field' fields need to be populated from the SQL Table.

Does anyone have any experience in mapping SQL table source to JSON sink?
Any help would be greatly appreciated.

{
  "Object1": {
    "Object2": {
      "@Field1": "",
      "Fields": {
        "Field2": 0,
        "Field3": "",
        "Field4": ""
      }
    }
  }
}
Azure Data Factory
Azure Data Factory

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


Answer accepted by question author
AnnuKumari-MSFT 34,571 Reputation points Microsoft Employee Moderator
2023-03-28T10:00:38.0766667+00:00

Hi @Robbin Berger ,

Welcome to Microsoft Q&A platform and thanks for posting your question here. As I understand your query, you are trying to copy data from SQL table to JSON file whose structure is already defined. Kindly let me know if that is not the ask here.

Could you please try removing @ symbol before Field1 and see if it works?

mapping

You can also use derived column transformation of Mapping dataflow in azure datafactory to create nested json using Add subcolumn options.

For more details, kindly check the following videos:

How to convert a JSON record into NESTED JSON using mapping dataflow

Load CSV file in to JSON with Nested Hierarchy using Azure data factory


Hope it helps. Kindly accept the answer by clicking on Accept answer button. Thanks

Was this answer helpful?

1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Robbin Berger 20 Reputation points
    2023-03-31T09:48:37.1733333+00:00

    Knipsel

    Was this answer helpful?

    0 comments No comments

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.