[英]dotLiquid template for Azure Logic Apps' SQL Execute Query output
Azure 邏輯應用程序的 SQL 執行查詢操作返回 JSON 輸出,如下所示:
[
[
{
"ProductID": 7000,
"ProductName": "Some name"
},
...
]
]
在 Azure 邏輯應用 JSON 到 JSON 轉換操作中與 dotLiquid 一起使用什么語法是正確的,以迭代這些嵌套數組以擺脫嵌套,例如生成如下內容:
{
"products": [
{
"productId": 7000,
"productName": "Some name"
},
...
]
}
由於您無論如何都將使用集成帳戶,因此可以使用邏輯應用程序中的“ 執行 JavaScript 代碼”操作通過以下代碼輕松完成此轉換:
var input_array = workflowContext.actions.Compose.outputs;
var output = { "products": [] };
for (let i = 0; i < input_array.length; i++) {
for (let j = 0; j < input_array[i].length; j++) {
output.products.push(input_array[i][j]);
}
}
return output;
結果:
經過不斷的反復試驗,我得出了這個解決方案:
{
"products": [
{% for product in content[0] %}
{
"productId": {{ product.ProductID }}
}{% unless forloop.last %},{% endunless %}
{% endfor %}
]
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.