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] 日期转json字串时出现\u0000 #516

Closed
zhanglizhi77 opened this issue Jun 29, 2022 · 9 comments
Closed

[BUG] 日期转json字串时出现\u0000 #516

zhanglizhi77 opened this issue Jun 29, 2022 · 9 comments
Labels
bug Something isn't working
Milestone

Comments

@zhanglizhi77
Copy link

问题描述

简要描述您碰到的问题。

从object转json字串时,对日期字段的转换出现
"2022-02-21 14:33:02.012\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000"
我测试发现,IBM JDK不能正常转换,Oracle官方JDK可以,OpenJDK没有测试。

环境信息

请填写以下信息:

  • OS信息: Windows 10家庭版 4Core 3.10GHz 32 GB
  • JDK信息:IBM JDK 1.8.0_322
  • 版本信息:Fastjson2 2.0.8

重现步骤

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

随意的对象(含Date类型字段)序列化成json字串

期待的正确结果

对您期望发生的结果进行清晰简洁的描述。
可以按指定格式输出日期字串,如
JSON.toJSONString(data, "yyyy-MM-dd HH:mm:ss.SSS");

相关日志输出

请复制并粘贴任何相关的日志输出。
{
"birthDate": "2022-02-21 14:33:02.012\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000"
}

附加信息

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

@zhanglizhi77 zhanglizhi77 added the bug Something isn't working label Jun 29, 2022
@wenshao
Copy link
Member

wenshao commented Jun 29, 2022

data是什么类型?

@zhanglizhi77
Copy link
Author

data是个随意的类型,比如
class ClassA{
private Date birthDate;//这个字段转json字串有问题
}

@wenshao
Copy link
Member

wenshao commented Jun 29, 2022

很奇怪,我没有重现问题

@zhanglizhi77
Copy link
Author

是使用的IBM JDK 1.8.0_322吗?
IBM的

@wenshao
Copy link
Member

wenshao commented Jun 29, 2022

不是的,我手上没有IBM JDK的环境

@zhanglizhi77
Copy link
Author

是否可以安装下环境试下呢?还是我将问题关闭了?
https://developer.ibm.com/languages/java/semeru-runtimes/downloads/

@wenshao
Copy link
Member

wenshao commented Jun 30, 2022

我来做验证吧

@wenshao
Copy link
Member

wenshao commented Jun 30, 2022

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.9-SNAPSHOT/
在IBM OpenJ9 8.0上确实是有问题,问题已修复,请帮忙更新快照2.0.9-SNAPSHOT验证,2.0.9版本预计在7月10日发布

@wenshao wenshao added this to the 2.0.9 milestone Jun 30, 2022
@wenshao
Copy link
Member

wenshao commented Jul 10, 2022

https://github.com/alibaba/fastjson2/releases/tag/2.0.9
问题已修复,请用新版本

@wenshao wenshao closed this as completed Jul 10, 2022
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

2 participants