Is there a way to flatten the following rather inconvenient type of JSON object in Azure Data Factory (V2)? Top-level keys in the data represent dynamically generated dates, which are different in each file. Hence, the schema is drifting.
I would like to flatten the data by unrolling the members
array under each date key. Please see sample input and desired output below.
I haven't found a way to achieve this in a Mapping Data Flow. The Flatten activity does not seem to work since the schema cannot be defined, and I am not unrolling single array but many. My second attempt was to use Unpivot to transpose each date to a row and then flatten, but it seems that the complex type is not supported for unpivoted values.
Input sample
{
"2021-01-01": {
"total": 30,
"members": [
{
"name": "foo",
"value": 10
},
{
"name": "bar",
"value": 20
}
]
},
"2021-01-02": {
"total": 70,
"members": [
{
"name": "foo",
"value": 30
},
{
"name": "john",
"value": 40
}
]
}
}
Desired tabular output
|
name |
value |
2021-01-01 |
foo |
10 |
2021-01-01 |
bar |
20 |
2021-01-02 |
foo |
30 |
2021-01-02 |
john |
40 |
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…