Azure 逻辑应用程序从 HTTP 调用解析复杂的 JSON

问题描述

我正在构建逻辑应用程序并尝试进行一些错误处理。我正在 http 调用中执行操作,然后如果失败,我想读取正文并输出错误消息。 http 调用失败后输出以下内容

"error": {
    "code": "BadRequest","message": "","innerError": {
      "date": "date","request-id": "id","client-request-id": "id"
    }
  }

我正在解析这个 JSON,但我遇到了架构问题,这是我最近的尝试,但对我来说失败了:

{
    "properties": {
        "error": {
            "properties": {
                "code": {
                    "type": "string"
                },"message": {
                    "type": "string"
                }
            },"type": "object"
        },"type": "object"
    },"type": "object"
}

如果有人也能解释一下逻辑就好了

解决方法

也许你可以试试这个模式:

{
    "properties": {
        "error": {
            "properties": {
                "code": {
                    "type": "string"
                },"innerError": {
                    "properties": {
                        "client-request-id": {
                            "type": "string"
                        },"date": {
                            "type": "string"
                        },"request-id": {
                            "type": "string"
                        }
                    },"type": "object"
                },"message": {
                    "type": "string"
                }
            },"type": "object"
        }
    },"type": "object"
}