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.toJSONString打印包含boolan类型对象会多出属性值 #599

Closed
leblancvn opened this issue Jul 29, 2022 · 2 comments
Closed
Labels
bug Something isn't working
Milestone

Comments

@leblancvn
Copy link

问题描述

使用FieldBased无法映射is开头的boolean类型,在打印解析对象的时候会多一个属性值,并且会影响下面的toJSONString打印结果

环境信息

  • JDK信息: [e.g.:jdk 1.8]
  • 版本信息:[e.g.:Fastjson2 2.0.10]

重现步骤

测试类:
@DaTa
public class TestB {
private boolean isSuccess = false;
}
测试方法:
public static void main(String[] args) {
String str = "{"success":true}";
TestB testB = JSON.parseObject(str, TestB.class, JSONReader.Feature.FieldBased);
System.out.println(JSON.toJSONString(testB));
TestB testB1 = new TestB();
testB1.setSuccess(true);
System.out.println(JSON.toJSONString(testB1));
}

期待的正确结果

期望打印
{"success":false}
{"success":true}

相关日志输出

{"isSuccess":false,"success":false}
{"isSuccess":true,"success":true}

@leblancvn leblancvn added the bug Something isn't working label Jul 29, 2022
@wenshao wenshao added this to the 2.0.11 milestone Jul 30, 2022
@wenshao
Copy link
Member

wenshao commented Jul 30, 2022

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.11-SNAPSHOT/
问题已修复,请用2.0.11-SNAPSHOT版本帮忙验证,2.0.11版本预计在8月7日发布

@wenshao
Copy link
Member

wenshao commented Aug 7, 2022

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

@wenshao wenshao closed this as completed Aug 7, 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