我有一个 JSON 对象,其中包含一个没有键的嵌套数组。我想从这个嵌套数组中提取所有元素,将每个元素分配给具有适当名称的单独列,并将数据放入 SQL 表中。目标是为每个“name”和“display_name”对生成一条记录。
下面是输入的 JSON 对象。
{
"took": 573,
"_revision": "8ac1368",
"response": {
"accounts": {
"hits": [{
"name": "Nilesh",
"display_name": "Nilesh",
"selected_fields": [
"Class",
null,
10,
"Physics",
17,
14,
"Rohit"
]
},
{
"name": "Ronak",
"display_name": "Ronak",
"selected_fields": [
"Class",
null,
10,
"Chemistry",
18,
14,
"Rahul"
]
},
{
"name": "Puneet",
"display_name": "Puneet",
"selected_fields": [
"Class",
null,
10,
"Mathematics",
13,
15,
"Priyam"
]
},
{
"name": "Sanyam",
"display_name": "Sanyam",
"selected_fields": [
"Class",
null,
10,
"English",
14,
15,
"Priyanshu"
]
}
],
"stats": {},
"total_hits": 5811
}
},
"service_id": "25163",
"_type": "status",
"_version": 1,
"status": "success"
}
我被困在这一点上,并努力将行数据扩展到列(参见上面的输出屏幕截图)。我正在寻找有关后续步骤的指导。
要根据输出展平数组数据,您需要在 ADF 数据流中进行以下设置。
response.accounts.hits[]
数组。name = response.accounts.hits.name,
Display_name = response.accounts.hits.display_name,
response = response.accounts.hits.selected_fields
identify = response[1],
{Blood group} = response[2],
Standard = response[3],
Subject = response[4],
{Roll no} = response[5],
Age = response[6],
{Class Teacher} = response[7]