Azure 逻辑应用程序解析 Json 引发错误

Azure logic apps Parse Json throws an error

背景

我有一个自定义连接器,它 returns 一个 JSON 响应。我正在尝试解析对 JSON 的响应,因为我想稍后在其他流程中使用该响应。所以我正在使用来自数据操作连接器的 Parse JSON 操作。以下是 JSON 响应和我提供给 Parse JSON 的 JSON 模式 JSON。

响应

[
   [
      {
         "key":"Customer_Key",
         "value":{
            "id":"abfa48ad-392d-e511-80d3-005056b34214",
            "name":"90033"
         }
      },
      {
         "key":"Status",
         "value":"Done"
      }
   ]
]

架构

{
    "type": "array",
    "items": {
        "type": "array",
        "items": {
            "type": "object",
            "properties": {
                "key": {
                    "type": "string"
                },
                "value": {
                    "type": "object",
                    "properties": {
                        "id": {
                            "type": "string"
                        },
                        "name": {
                            "type": "string"
                        }
                    }
                }
            },
            "required": [
                "key",
                "value"
            ]
        }
    }
}

异常

  {
            "message": "Invalid type. Expected Object but got String.",
            "lineNumber": 0,
            "linePosition": 0,
            "path": "[0][2].value",
            "value": "90033",
            "schemaId": "#/items/items/properties/value",
            "errorType": "type",
            "childErrors": []
        },

有人知道这是什么问题吗?我们如何转换上面的 json 响应

架构看起来不正确。尝试使用以下架构:

{
  "type": "array",
  "items": [
    {
      "type": "array",
      "items": [
        {
          "type": "object",
          "properties": {
            "key": {
              "type": "string"
            },
            "value": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "name"
              ]
            }
          },
          "required": [
            "key",
            "value"
          ]
        },
        {
          "type": "object",
          "properties": {
            "key": {
              "type": "string"
            },
            "value": {
              "type": "string"
            }
          },
          "required": [
            "key",
            "value"
          ]
        }
      ]
    }
  ]
}

看起来 Use sample payload to generate schema 无法生成正确的架构。 所以你可以去这个 liquid studio site 并粘贴 JSON 有效载荷然后点击 Generate Schema 按钮,然后你将获取 Json 架构。

我测试了架构,它运行良好。

希望对您有所帮助,如果您还有其他问题,请告诉我。