Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

接口返回List<T>解析错误问题 #31

Open
darrenzhou2017666 opened this issue Nov 12, 2024 · 3 comments
Open

接口返回List<T>解析错误问题 #31

darrenzhou2017666 opened this issue Nov 12, 2024 · 3 comments

Comments

@darrenzhou2017666
Copy link

问题描述

如果第三方接口返回的是:

[
      {
        "name": "张三",
        "position": "语文",
        "age": 15,
        "class": 1
      },
    {
        "name": "张三2",
        "position": "语文2",
        "age": 15,
        "class": 1
      }
]

这种数组结构的json,则系统解析会报错,出错原因是 这部分代码:
Map<String,Object> map = JsonSerializeHelper.deserialize(resultContent, Map.class);反序列化错误;

@somta
Copy link
Owner

somta commented Nov 15, 2024

问题描述

如果第三方接口返回的是:

[
      {
        "name": "张三",
        "position": "语文",
        "age": 15,
        "class": 1
      },
    {
        "name": "张三2",
        "position": "语文2",
        "age": 15,
        "class": 1
      }
]

这种数组结构的json,则系统解析会报错,出错原因是 这部分代码: Map<String,Object> map = JsonSerializeHelper.deserialize(resultContent, Map.class);反序列化错误;

这里是由于接口结构不确定导致的,实际接口定义过程中,一般接口还会有接口状态码,接口错误信息等统一参数,因此这种情况在实际开发中,属于少数情况,我们目前还没有想到非常优雅的解决方案,有好的方案后会修复

@desert-wolfs
Copy link
Collaborator

数组结构怎么能转换成map呢, 一个是多个对象的集合,一个是单个对象

@somta
Copy link
Owner

somta commented Dec 26, 2024

数组结构怎么能转换成map呢, 一个是多个对象的集合,一个是单个对象

具体希望从什么样的数组转换成什么样的map,可以给个示例,目前通过代码节点是可以任意转换的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants