Azure数据工厂-如何处理JSON数据中的嵌套数组以导入到Blob存储

时间:2019-05-20 12:53:13

标签: azure-storage-blobs azure-data-factory

我正在创建用于将JSON数据从REST源导入Blob存储的管道。 但是,我有一个问题,因为包含主数据的数组内部有一个嵌套数组。

JSON数据如下:

{
  "@odata.context": "<Context>",
  "@odata.nextLink": "<Next Link>",
  "value": [
    {
      "@odata.type": "<Type>",
      "reportRefreshDate": "2019-05-18",
      "userPrincipalName": "abc@xyz.net",
      "displayName": "abc",
      "isDeleted": false,
      "deletedDate": null,
      "hasExchangeLicense": true,
      "hasOneDriveLicense": true,
      "hasSharePointLicense": true,
      "hasSkypeForBusinessLicense": true,
      "hasYammerLicense": true,
      "hasTeamsLicense": true,
      "exchangeLastActivityDate": "2019-05-17",
      "oneDriveLastActivityDate": null,
      "sharePointLastActivityDate": null,
      "skypeForBusinessLastActivityDate": null,
      "yammerLastActivityDate": null,
      "teamsLastActivityDate": null,
      "exchangeLicenseAssignDate": "2019-03-19",
      "oneDriveLicenseAssignDate": "2018-07-06",
      "sharePointLicenseAssignDate": "2018-07-06",
      "skypeForBusinessLicenseAssignDate": "2018-05-22",
      "yammerLicenseAssignDate": "2018-05-22",
      "teamsLicenseAssignDate": "2018-05-22",
      "assignedProducts": [
        "OFFICE 365 E3",
        "OFFICE 365 E5"
      ]
    }
  ]
}

您可能会在这里注意到,在主数组“值”中有一个名为“ assignedProducts”的嵌套数组

我定义了Blob存储的架构,如下所示: enter image description here

当我定义源和接收器之间的映射时,无法映射嵌套数组,它显示如下:

enter image description here

据我所知,有可能为该数组创建一个循环。但是对于嵌套数组,这似乎很困难。

有人可以建议我如何处理嵌套数组吗?如果将此数组转换为字符串或其他内容,那就更好了。

预先感谢:-)

1 个答案:

答案 0 :(得分:0)

我模拟了一些像您一样的样本数据:

    Private Sub FillFormatTextBox()
    Dim Format As Object = Nothing
    Dim strSQL = "SELECT Report_Format FROM tb_setup_format_type WHERE status ='1' and ID = @ID "
    Using cn As New SqlConnection("Your connection string")
        Using cmd As New SqlCommand(strSQL, cn)
            'Your code did not provide a value for the Id parameter
            cmd.Parameters.Add("@ID", SqlDbType.Int).Value = 4
            cn.Open()
            Format = cmd.ExecuteScalar()
        End Using
    End Using
    If Format Is Nothing Then
        MessageBox.Show("No format Found")
    Else
        txtformat.Text = Format.ToString.Trim
    End If
End Sub

然后按如下所示配置Blob存储数据集,请将[ { "numberArray":[ "1", "2", "3" ], "name":"A" }, { "numberArray":[ "4", "5", "6" ], "name":"B" } ] 设置为File Pattern

enter image description here

结果:

enter image description here