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

fastjson2序列化的结果和fastjson1不一致。 #970

Closed
599166320 opened this issue Nov 27, 2022 · 4 comments
Closed

fastjson2序列化的结果和fastjson1不一致。 #970

599166320 opened this issue Nov 27, 2022 · 4 comments
Labels
bug Something isn't working fixed
Milestone

Comments

@599166320
Copy link

599166320 commented Nov 27, 2022

问题描述

fastjson2序列化的结果和fastjson1不一致。

环境信息

请填写以下信息:

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

重现步骤

@Setter
@Getter
public class MyBean{
	private String qStr;
}



JSONObject obj = new JSONObject();
obj.put("qStr","abc");

MyBean mybean = obj.toJavaObject(MyBean.class);
System.out.println(JSON.toJSONString(mybean));



fastjson2最新版本
{"QStr":"abc"}

fastjon1
{qStr":"abc"}

期待的正确结果

fastjson1和fastjson2输出一致。

@599166320 599166320 added the bug Something isn't working label Nov 27, 2022
@599166320 599166320 changed the title [BUG] fastjson2序列化的结果和fastjson1不一致。 Nov 27, 2022
@kraity
Copy link
Collaborator

kraity commented Nov 29, 2022

通过注解@getter, 会得到setQStr(String)方法. 不兼容原因你可以查看PR Camelcase#issuecomment-1181634178

@599166320
Copy link
Author

@kraity 感谢回复。我也已经注意了。如果项目使用lombok,又想升级fastjson2,会有一定的风险。

@wenshao
Copy link
Member

wenshao commented Dec 18, 2022

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson/2.0.22-SNAPSHOT/
问题已经修复,使用兼容API保持原来的命名风格输出,请帮忙用2.0.22-SNAPSHOT版本验证,2.0.22版本预计在元旦期间发布

@wenshao wenshao added the fixed label Dec 18, 2022
@wenshao wenshao added this to the 2.0.22 milestone Dec 18, 2022
@wenshao
Copy link
Member

wenshao commented Dec 31, 2022

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

@wenshao wenshao closed this as completed Dec 31, 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 fixed
Projects
None yet
Development

No branches or pull requests

3 participants