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]hutool中CaseInsensitiveMap、CaseInsensitiveLinkedMap等相关的map类型序列化问题 #2458

Closed
1195952223 opened this issue Apr 18, 2024 · 6 comments
Labels
bug Something isn't working fixed
Milestone

Comments

@1195952223
Copy link

1195952223 commented Apr 18, 2024

问题描述

简要描述您碰到的问题。

环境信息

请填写以下信息:

  • 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.49]

重现步骤

如何操作可以重现该问题:

  1. 使用 xxx.xxx 方法
  2. 输入 ... 数据
  3. 出现 ... 错误
    public static void main(String[] args) {
        Map m2 = new CaseInsensitiveLinkedMap();
        m2.put("a", "V");
        System.out.println(JSON.toJSONString(m2, JSONWriter.Feature.FieldBased, JSONWriter.Feature.WriteNullStringAsEmpty));
        System.out.println(JSON.toJSONString(m2, JSONWriter.Feature.WriteNullStringAsEmpty));

    }

期待的正确结果

对您期望发生的结果进行清晰简洁的描述。
2种序列化结果一致

相关日志输出

请复制并粘贴任何相关的日志输出。
{"raw":{"a":"V"}}
{"a":"V"}

附加信息

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

@1195952223 1195952223 added the bug Something isn't working label Apr 18, 2024
@1195952223 1195952223 changed the title [BUG]hutool中CaseInsensitiveLinkedMap等相关的map类型序列化问题 [BUG]hutool中CaseInsensitiveMap、CaseInsensitiveLinkedMap等相关的map类型序列化问题 Apr 18, 2024
@wenshao wenshao added this to the 2.0.50 milestone Apr 18, 2024
wenshao added a commit that referenced this issue Apr 19, 2024
@wenshao wenshao added the fixed label Apr 19, 2024
@wenshao
Copy link
Member

wenshao commented Apr 19, 2024

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.50-SNAPSHOT/
已经支持,请帮忙用2.0.50-SNAPSHOT版本验证

@1195952223
Copy link
Author

1195952223 commented Apr 19, 2024

还有其他的类型这个是主类cn.hutool.core.map.MapWrapper 还有就是我继承的类 现在这种判断方式还是不行
image
image

@1195952223
Copy link
Author

Map.class.isAssignableFrom(objectClass) 这种方式是否可行

@wenshao
Copy link
Member

wenshao commented Apr 19, 2024

有些Map的实现的字段不能忽略的,不可行

@1195952223
Copy link
Author

好的 能在类上通过加注解或者其他方式解决吗

@wenshao
Copy link
Member

wenshao commented May 12, 2024

https://github.com/alibaba/fastjson2/releases/tag/2.0.50
2.0.50已发布,请用新版本

@wenshao wenshao closed this as completed May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

2 participants