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

[BUG]字符串中有@type且位置不在json串开始位置,用JSON.parseObject(string, clz, Feature.SupportAutoType, Feature.SupportNonPublicField)反序列化时结果跟fastjson1不一致 #3284

Open
BabyQiPuppy opened this issue Jan 16, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@BabyQiPuppy
Copy link

BabyQiPuppy commented Jan 16, 2025

问题描述

简要描述您碰到的问题。
使用JSON.parseObject(string, clz, Feature.SupportAutoType, Feature.SupportNonPublicField)反序列化{"endDataTime":"2024","@type":"java.util.HashMap","startDataTime":"2023"}后在1.X版本不带@type,在2.x带@type。期望不带@type

环境信息

请填写以下信息:

  • OS信息: [e.g.:CentOS 8.4.2105 4Core 3.10GHz 16 GB]
  • JDK信息: [e.g.:Openjdk 1.8.0_312]
  • 版本信息:[e.g.:Fastjson2 2.0.52]

重现步骤

如何操作可以重现该问题:
String result = "{"parametersMap":{"endDataTime":"2018","@type":"java.util.HashMap","startDataTime":"2017"}}";
Object obj = JSON.parseObject(result, Test.class, Feature.SupportAutoType, Feature.SupportNonPublicField);

public class Test {
private HashMap<String, String> parametersMap;

public HashMap<String, String> getParametersMap() {
    return parametersMap;
}

public void setParametersMap(HashMap<String, String> parametersMap) {
    this.parametersMap = parametersMap;
}

}

  1. 使用 xxx.xxx 方法
  2. 输入 ... 数据
  3. 出现 ... 错误
//可在此输入示例代码

期待的正确结果

对您期望发生的结果进行清晰简洁的描述。

Image

相关日志输出

请复制并粘贴任何相关的日志输出。

Image

附加信息

如果你还有其他需要提供的信息,可以在这里填写(可以提供截图、视频等)。

@BabyQiPuppy BabyQiPuppy added the bug Something isn't working label Jan 16, 2025
@BabyQiPuppy BabyQiPuppy changed the title [BUG] [BUG]JSON.parseObject(string, clz, Feature.SupportAutoType, Feature.SupportNonPublicField)反序列化带@type Jan 16, 2025
@BabyQiPuppy BabyQiPuppy changed the title [BUG]JSON.parseObject(string, clz, Feature.SupportAutoType, Feature.SupportNonPublicField)反序列化带@type [BUG]字符串中有@type且位置不在json串开始位置,用JSON.parseObject(string, clz, Feature.SupportAutoType, Feature.SupportNonPublicField)反序列化时表现跟fastjson1不一致 Jan 18, 2025
@BabyQiPuppy BabyQiPuppy changed the title [BUG]字符串中有@type且位置不在json串开始位置,用JSON.parseObject(string, clz, Feature.SupportAutoType, Feature.SupportNonPublicField)反序列化时表现跟fastjson1不一致 [BUG]字符串中有@type且位置不在json串开始位置,用JSON.parseObject(string, clz, Feature.SupportAutoType, Feature.SupportNonPublicField)反序列化时结果跟fastjson1不一致 Jan 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant