You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

解决Logic Apps ParseJson中“Invalid type”错误:Schema问题排查

问题描述

遇到的错误

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

当前使用的ParseJson Schema

{
    "items": {
        "items": {
            "properties": {
                "AttachmentName": {
                    "type": "string"
                },
                "CopyFileFormat": {
                    "type": "string"
                },
                "EmailSubject": {
                    "type": "string"
                },
                "FromEmailDomain": {
                    "type": "string"
                },
                "copypath": {
                    "type": "string"
                }
            },
            "required": [
                "EmailSubject",
                "FromEmailDomain",
                "AttachmentName",
                "copypath",
                "CopyFileFormat"
            ],
            "type": "array"
        },
        "type": "array"
    },
    "type": "array"
}

存储过程执行输出结果

{
  "ResultSets": {
    "Table1": [
      {
        "EmailSubject": "test Value",
        "FromEmailDomain": "gmail.com",
        "AttachmentName": "test0804.PDF",
        "copypath": "test",
        "CopyFileFormat": "202304.pdf"
      }
    ]
  },
  "ReturnCode": 0,
  "OutputParameters": {}
}
问题原因及解决方法

问题原因

你的ParseJson Schema与存储过程输出的JSON结构完全不匹配:

  • 存储过程输出是顶层对象,包含ResultSets、ReturnCode、OutputParameters三个属性,但你的Schema定义顶层为数组,这是核心错误来源。
  • 你嵌套了多层数组类型,但实际有效数据在ResultSets.Table1下的数组中,每个元素是单个对象,而非数组。

修正后的完整ParseJson Schema

直接匹配存储过程的完整输出结构即可,正确Schema如下:

{
    "type": "object",
    "properties": {
        "ResultSets": {
            "type": "object",
            "properties": {
                "Table1": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "EmailSubject": {
                                "type": "string"
                            },
                            "FromEmailDomain": {
                                "type": "string"
                            },
                            "AttachmentName": {
                                "type": "string"
                            },
                            "copypath": {
                                "type": "string"
                            },
                            "CopyFileFormat": {
                                "type": "string"
                            }
                        },
                        "required": [
                            "EmailSubject",
                            "FromEmailDomain",
                            "AttachmentName",
                            "copypath",
                            "CopyFileFormat"
                        ]
                    }
                }
            },
            "required": [
                "Table1"
            ]
        },
        "ReturnCode": {
            "type": "integer"
        },
        "OutputParameters": {
            "type": "object"
        }
    },
    "required": [
        "ResultSets",
        "ReturnCode",
        "OutputParameters"
    ]
}

简化方案(仅处理有效数据)

如果Logic Apps只需要Table1中的数据,可先通过Compose或Select操作提取ResultSets.Table1,再对该数组使用ParseJson,此时Schema可简化为:

{
    "type": "array",
    "items": {
        "type": "object",
        "properties": {
            "EmailSubject": {
                "type": "string"
            },
            "FromEmailDomain": {
                "type": "string"
            },
            "AttachmentName": {
                "type": "string"
            },
            "copypath": {
                "type": "string"
            },
            "CopyFileFormat": {
                "type": "string"
            }
        },
        "required": [
            "EmailSubject",
            "FromEmailDomain",
            "AttachmentName",
            "copypath",
            "CopyFileFormat"
        ]
    }
}

内容的提问来源于stack exchange,提问作者Gopal Kanjolia

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.14 01:53:14