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

TIBCO BW6解析含嵌套数组JSON报错求助

TIBCO BW6嵌套数组JSON解析错误修复方案

错误原因

你遇到的TIBCO-BW-PALETTE-REST-100016错误,核心原因是JSON的data字段为嵌套数组结构(一个数组包含多个字符串子数组),但你的XSD将data定义为可重复的顶级元素,与JSON的结构不匹配,导致JSON到XML的映射无法完成。

修正后的XSD

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="root">
    <xs:complexType>
        <xs:sequence>
            <xs:element type="xs:string" name="hasMore"/>
            <xs:element type="xs:integer" name="totalResults" />
            <xs:element type="xs:integer" name="count" />
            <xs:element type="xs:integer" name="limit" />
            <xs:element type="xs:integer" name="offset" />
            <xs:element maxOccurs="unbounded" type="xs:string" name="columns" minOccurs="0"/>
            <!-- 修改data的结构:单一元素包含多个row,每个row对应JSON子数组 -->
            <xs:element name="data" minOccurs="0">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="row" maxOccurs="unbounded">
                            <xs:complexType>
                                <xs:sequence>
                                    <xs:element name="dataItem" maxOccurs="unbounded" type="xs:string"/>
                                </xs:sequence>
                            </xs:complexType>
                        </xs:element>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>
</xs:element>
</xs:schema>

修改说明

  1. 移除原XSD中data元素的maxOccurs="unbounded",将其定义为单一元素,对应JSON中唯一的data字段
  2. 在data内部新增row元素(maxOccurs="unbounded"),对应JSON数组中的每个子数组
  3. 每个row内部保留dataItem元素,对应子数组中的每个字符串值

转换后的XML示例

修正后,JSON将正确转换为以下符合XSD的XML结构:

<root>
    <hasMore>true</hasMore>
    <totalResults>2000</totalResults>
    <count>2</count>
    <limit>2</limit>
    <offset>0</offset>
    <columns>CITY</columns>
    <columns>ADDRESS_COUNTRY</columns>
    <data>
        <row>
            <dataItem>Waltham</dataItem>
            <dataItem>US</dataItem>
        </row>
        <row>
            <dataItem>Delhi</dataItem>
            <dataItem>IND</dataItem>
        </row>
    </data>
</root>

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.12 19:20:09