Skip to content

SupportAutoType 模式下嵌套的HashMap 转换失败 #2693

@liuzhenpeng

Description

@liuzhenpeng

问题描述

SupportAutoType 模式下嵌套的HashMap 转换失败

环境信息

请填写以下信息:

  • OS信息:window
  • JDK信息: [e.g.:Openjdk 1.8.0_312]
  • 版本信息::Fastjson2 2.0.50

重现步骤

class FormInstance{
String id
Map<String, Object> widgets
}
String str="{"@type":"com.example.FormInstance","id":"jdjdjksjkjskddd111","widgets":{"@type":"java.util.HashMap","_S_SERIAL":"LYBD-20240611-001"}}"

FormInstance formInstance = JSON.parseObject(str, FormInstance.class,Feature.SupportAutoType);
转换后 widgets 为空,

  1. 使用 JSON.parseObject(str, FormInstance.class,Feature.SupportAutoType);
  2. FormInstance formInstance = JSON.parseObject(str, FormInstance.class,Feature.SupportAutoType);
  3. 出现 ... 错误
    转换后 widgets 为空

期待的正确结果

widgets 能够转换为HashMap

附加信息

如果你还有其他需要提供的信息,可以在这里填写(可以提供截图、视频等)。
FastJson1.2.83是正常可以支持的

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixed

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions