将Azure数据工厂中的嵌套JSON映射到原始对象

时间:2020-04-09 10:31:35

标签: json azure-data-factory azure-data-factory-2

由于ADF(Azure数据工厂)无法处理复杂/嵌套的JSON对象,因此我在SQL中使用OPENJSON来解析对象。但是,我无法从以下对象获取“原始” JSON:

{
   "rows":[
      {
         "name":"Name1",
         "attribute1":"attribute1",
         "attribute2":"attribute2"
      },
      {
         "name":"Name2",
         "attribute1":"attribute1",
         "attribute2":"attribute2"
      },
      {
         "name":"Name3",
         "attribute1":"attribute1",
         "attribute2":"attribute2"
      }
   ]
}

配置1

当我使用此配置时:enter image description here

我得到列出的所有名字

  1. Name1
  2. Name2
  3. Name3

结果:

enter image description here

配置2

当我使用此配置时:

enter image description here

我在一条记录中获得了整个JSON:

  1. [{{full JSON}}]

结果:

enter image description here

需要的配置

但是,我想要的是这个结果:

  1. {“ name”:“ Name1”,“ attribute1”:“ attribute1”,“ attribute2”:“ attribute2}
  2. {“ name”:“ Name2”,“ attribute1”:“ attribute1”,“ attribute2”:“ attribute2}
  3. {“ name”:“ Name3”,“ attribute1”:“ attribute1”,“ attribute2”:“ attribute2}

结果:

enter image description here

因此,我需要Config 1的迭代,每行具有原始JSON。每次我使用$ ['rows']或$ ['rows'] [0]时,似乎都“忘记了”进行迭代。

有人吗?

2 个答案:

答案 0 :(得分:0)

您是否尝试过数据流来处理JSON结构?我们具有内置的功能,可以进行数据流转换,例如派生列,展平和接收器映射。

答案 1 :(得分:0)

活动副本可以帮助我们实现这一目标。

例如,我将B.json fron容器“ backup”复制到另一个Blob容器“ testcontainer”。

这是我的B.json源数据集:

enter image description here

来源:

enter image description here

下沉: enter image description here

映射:

enter image description here

管道成功执行:

enter image description here

检查testcontainer中的数据:

enter image description here

希望这会有所帮助。


更新

将嵌套的json复制到SQL。

来源与blob中的B.json相同。

接收器数据集:

enter image description here

下沉:

enter image description here

映射:

enter image description here

运行管道:

enter image description here

检查SQL数据库中的数据:

enter image description here