json - 检查 JSON 响应中是否存在关键字 - Azure 逻辑应用

标签 json azure azure-logic-apps

在我的 Azure 逻辑应用程序中,我有一个从 SQL 数据库获取行的操作,如下所示。

enter image description here

其示例输出(主体)如下,

{
  "@odata.context": "https://logic-apis-southeastasia.azure-apim.net/apim/sql/5bb78f1b756e4b6097a8bccb6be8dae7/$metadata#datasets('virtueagintegrationssqldbsv-dev2.database.windows.net%2CLearnIntegrationDB-dev2')/tables('%5Bdbo%5D.%5BLearnEmployeeExamData%5D')/items",
  "value": [
    {
      "@odata.etag": "",
      "ItemInternalId": "ddf29856-4452-4511-a041-83a4bcf3e8fc",
      "EXAMSTART": "YES",
      "EXAMRESULT": "YES"
    },
    {
      "@odata.etag": "",
      "ItemInternalId": "b5a0261b-c5bf-4f14-8a87-a6acd3aaa26b",
      "EXAMSTART": "YES",
      "EXAMRESULT": "YES"
    },
    {
      "@odata.etag": "",
      "ItemInternalId": "7035458b-605d-431e-a352-dc91261f2a59"
    },
    {
      "@odata.etag": "",
      "ItemInternalId": "648d4c06-c3e0-45a9-b656-1aab485d12fd"
    }
  ]
}

是否有表达式来检查项目列表“值”中至少一项具有 "EXAMSTART": "YES" 如上面的响应所示?

例如:对于上述响应,它应该输出 True 因为它有两个这样的项目。

最佳答案

您可以使用数据操作-> 过滤数组步骤仅获取带有EXAMSTART: "YES"的项目:

enter image description here enter image description here

enter image description here

然后使用 length评估是否有从Filter Array返回的任何数组项:

enter image description here

代码 View :

"Condition": {
    "actions": {},
    "expression": {
        "and": [
            {
                "greater": [
                    "@length(body('Filter_array'))",
                    0
                ]
            }
        ]
    },
    "runAfter": {
        "Filter_array": [
            "Succeeded"
        ]
    },
    "type": "If"
},
"Filter_array": {
    "inputs": {
        "from": "@body('Get_rows_(V2)')?['value']",
        "where": "@equals(item()?['EXAMSTART'], 'YES')"
    },
    "runAfter": {
        "Get_rows_(V2)": [
            "Succeeded"
        ]
    },
    "type": "Query"
},

关于json - 检查 JSON 响应中是否存在关键字 - Azure 逻辑应用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62730681/

相关文章:

javascript - 如何使用 AngularJS 在来自 REST 的 JSON 响应中创建可点击的 URL?

javascript - 如何摆脱本地 JSON 操作

azure - 托管解决方案的持续存储成本

error-handling - 如何从以前的连接器逻辑应用程序中获取错误消息

javascript - 如何在 javascript 中格式化 JSON 输出

Azure 计算模拟器 : Is it possible to control the IP of individual instances?

c# - 如何将 Azure 托管标识与 Azure.Storage.Blobs.BlobServiceClient 结合使用?

azure - 使用 Azure 逻辑应用将 HTTP 响应保存到 Blob 存储

python - 检查 SharePoint 中的文件是否已完成上传

json - 将 slice 结果 JSON 插入 MongoDB