Skip to content
New issue

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

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

Already on GitHub? # to your account

[BUG] JSONWriter.Feature.WriteLongAsString失效 #961

Closed
LLLLLLKKKKKK opened this issue Nov 24, 2022 · 1 comment
Closed

[BUG] JSONWriter.Feature.WriteLongAsString失效 #961

LLLLLLKKKKKK opened this issue Nov 24, 2022 · 1 comment
Labels
bug Something isn't working
Milestone

Comments

@LLLLLLKKKKKK
Copy link

问题描述

JavaBean转Json时,当JavaBean中Long型的值在[-1,1038]时,使用JSONWriter.Feature.WriteLongAsString会失效。

环境信息

  • JDK信息: [Openjdk 1.8.0_301]
  • 版本信息:[Fastjson2 2.0.19]

重现步骤

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

User user1 = new User(1038L);
String res1 = JSON.toJSONString(user1, JSONWriter.Feature.WriteLongAsString);
System.out.println(res1);  // {"id":1038}

User user2 = new User(1039L);
String res2 = JSON.toJSONString(user2, JSONWriter.Feature.WriteLongAsString);
System.out.println(res2);  // {"id":"1039"}

期待的正确结果

{"id":"1038"}

相关日志输出

{"id":1038}
{"id":"1039"}

@LLLLLLKKKKKK LLLLLLKKKKKK added the bug Something isn't working label Nov 24, 2022
@wenshao wenshao added this to the 2.0.20 milestone Nov 24, 2022
@wenshao
Copy link
Member

wenshao commented Nov 24, 2022

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.20-SNAPSHOT/
问题已修复,请帮忙用2.0.20-SNAPSHOT版本帮忙验证

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants