尝试插入从API获取的数据;它是一个嵌套数组。主要的一个“数据”包括id和类型,在某些情况下有一个“细分”数组,其中包括3个cols,标签百分比和计数。
我想把这个直接插入数据库然而,它没有意识到,当运行每个循环(有2个循环,一个用于数据阵列,最后一个用于分解阵列)时,对于一些ID,分解阵列是不存在的。
已尝试添加以下表达式:
if
(
equals(items('For_each')?['breakdown'], null),
json('[]'),
items('For_each')?['breakdown']
)
这已经停止了失败的逻辑应用程序,但它只是插入记录与细分数组只和忽略所有其他没有它。
解决这个问题的最佳方法是什么?
先谢谢你了。
附加信息,使用的负载示例:
{
"result_ok": true,
"total_count": 0,
"page": 1,
"total_pages": 1,
"results_per_page": 0,
"data": [
{
"id": 22,
"type": "INSTRUCTIONS"
},
{
"id": 26,
"type": "INSTRUCTIONS"
},
{
"id": 24,
"type": "INSTRUCTIONS"
},
{
"id": 25,
"type": "INSTRUCTIONS"
},
{
"id": 3,
"type": "IMAGE_SELECT",
"breakdown": [
{
"label": "Agree",
"percentage": "34.6",
"count": "256"
},
{
"label": "Neither agree nor disagree",
"percentage": "30.9",
"count": "229"
},
{
"label": "Strongly agree",
"percentage": "17.6",
"count": "130"
},
{
"label": "Disagree",
"percentage": "12.2",
"count": "90"
},
{
"label": "Strongly disagree",
"percentage": "4.7",
"count": "35"
}
],
"total responses": "740",
"sum": "0",
"average": 0,
"stdDev": null,
"min": null,
"max": null
},
{
"id": 6,
"type": "IMAGE_SELECT",
"breakdown": [
{
"label": "Agree",
"percentage": "41.9",
"count": "309"
},
{
"label": "Strongly agree",
"percentage": "25.4",
"count": "187"
},
{
"label": "Neither agree nor disagree",
"percentage": "19.8",
"count": "146"
},
{
"label": "Disagree",
"percentage": "9.6",
"count": "71"
},
{
"label": "Strongly disagree",
"percentage": "3.3",
"count": "24"
}
],
"total responses": "737",
"sum": "0",
"average": 0,
"stdDev": null,
"min": null,
"max": null
},
{
"id": 5,
"type": "IMAGE_SELECT",
"breakdown": [
{
"label": "Agree",
"percentage": "28.1",
"count": "208"
},
{
"label": "Neither agree nor disagree",
"percentage": "27.6",
"count": "204"
},
{
"label": "Strongly agree",
"percentage": "18.6",
"count": "138"
},
{
"label": "Disagree",
"percentage": "14.3",
"count": "106"
},
{
"label": "Strongly disagree",
"percentage": "11.4",
"count": "84"
}
],
"total responses": "740",
"sum": "0",
"average": 0,
"stdDev": null,
"min": null,
"max": null
},
{
"id": 7,
"type": "IMAGE_SELECT",
"breakdown": [
{
"label": "Agree",
"percentage": "39.1",
"count": "288"
},
{
"label": "Neither agree nor disagree",
"percentage": "23.7",
"count": "175"
},
{
"label": "Strongly agree",
"percentage": "23.5",
"count": "173"
},
{
"label": "Disagree",
"percentage": "9.6",
"count": "71"
},
{
"label": "Strongly disagree",
"percentage": "4.1",
"count": "30"
}
],
"total responses": "737",
"sum": "0",
"average": 0,
"stdDev": null,
"min": null,
"max": null
},
{
"id": 33,
"type": "IMAGE_SELECT",
"breakdown": [
{
"label": "Agree",
"percentage": "39.1",
"count": "286"
},
{
"label": "Strongly agree",
"percentage": "24.6",
"count": "180"
},
{
"label": "Neither agree nor disagree",
"percentage": "24.3",
"count": "178"
},
{
"label": "Disagree",
"percentage": "7.7",
"count": "56"
},
{
"label": "Strongly disagree",
"percentage": "4.4",
"count": "32"
}
],
"total responses": "732",
"sum": "0",
"average": 0,
"stdDev": null,
"min": null,
"max": null
},
{
"id": 12,
"type": "ESSAY"
},
{
"id": 13,
"type": "CHECKBOX",
"breakdown": [
],
"total responses": null,
"sum": null,
"average": null,
"stdDev": "0.00",
"min": "0.0",
"max": "0.0"
},
{
"id": 1,
"type": "INSTRUCTIONS"
}
]
}
1条答案
按热度按时间4uqofj5v1#
实现这一点的一种方法是通过将缺少的属性添加到具有null/空值的当前项来修改具有属性的当前项。下面是我的逻辑应用程序的流程。
For each
回路内的流量结果:
下面是我的逻辑应用程序的完整代码视图