thichxai
thichxai

Reputation: 1147

Azure ADF dataflow to exclude specify objects

I have multiple JSON files and use ADF dataflow to exclude the "record" and "contractNumbers" objects, retaining only the {"report":{"metadata":{...}}} objects. However, I am unable to structure the output JSON as expected. What other methods can resolve the problem of excluding unnecessary objects?

{
   "record": {
        "report": {
            "metadata": {
                "accessionNumber": "2004",
                "reportDate": {
                    "date": "2025-01-01"
                }
        },
        "contractNumbers": {
            "contractNumber": {
                "commercial": "ANS1002",
                "residental": "CA1191"
            }
        }
    }
 }
}

The result will be

{
 "report": {
        "metadata": {
            "accessionNumber": "2004",
            "reportDate": {
                "date": "2025-01-01"
            }
        }
    }

Filterter transformation: enter image description here

Derivedved transformation: enter image description here

Upvotes: 0

Views: 45

Answers (1)

Rakesh Govindula
Rakesh Govindula

Reputation: 11454

You can the combination of derived column and select transformations to achieve your requirement.

To select only the required objects from the reports object, first use a derived column transformation with below expression.

report - @(metadata=record.report.metadata)

Here, this will create an additional column named report which contains the required objects.

enter image description here

Now, use select transformation with a Rule-based mapping to select only the report column as shown below. Give the expression as name=='report'.

enter image description here

Now, you can see the required objects.

enter image description here

You can add your filter transformation for the accessionNumber before the derived column transformation.

I have used 3 JSON source files, and you can see there are 3 JSON objects in the result JSON file.

enter image description here

Upvotes: 0

Related Questions