JSON 没有键的数组 - 逻辑应用程序 Azure

JSON array without key - Logic Apps Azure

我的JSON数组如下

[{"20656":"20656","20648":"20648","20666":"20666","20657":"20657","20658":"20658","20659":"20659","20660":"20660","20665":"20665","20672":"20672","20667":"20667","24517":"24517","20677":"20677","20662":"20662","24605":"24605","20675":"20675","20663":"20663","20649":"20649","20664":"20664","20668":"20668","20669":"20669","20670":"20670","20671":"20671","20673":"20673","20674":"20674","20676":"20676"}]

如何使用每个单独的值并将其用作下一个查询的变量。

谢谢,

您可以使用 "Parse JSON" 操作来解析您的 json 数据。

首先,我创建一个 "Initialize variable" 操作来存储 json 数据(如下图所示)

然后创建"Parse JSON"动作来解析上面的json对象。

如果您不知道如何创建架构,可以单击 "Use sample payload to generate schema" 并将您的 json 数据输入其中。它会自动为您生成架构。也可以参考这个教程:https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-perform-data-operations#parse-json-action

之后,我们可以在我们的逻辑应用程序中使用每个单独的值作为变量。(我在下面的屏幕截图中创建了 "Initialize variable 2" 作为示例)。

假设你的变量看起来像这样

添加Select操作

其中 From 属性 设置为

split(replace(replace(replace(variables('MyJsonArray'),'[{',''),'}]',''),'"',''),',')

MapMyID 与表达式

配对
substring(item(),0,lastIndexOf(item(),':'))

现在您可以使用简单的 Foreach 简单地遍历所有 ID,并使用表达式

引用每个 ID
item()['MyID']