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

数组类型转json字符串设置WriteClassName后反序列化失败 #3217

Merged
merged 4 commits into from
Dec 22, 2024

Conversation

ra1nz
Copy link
Contributor

@ra1nz ra1nz commented Dec 22, 2024

What this PR does / why we need it?

使用JSON.toJSONString将一个数组类型转换为JSON字符串,如果设置了WriteClassName
String jsonString = JSON.toJSONString(new Object[]{1, 2, 3}, SerializerFeature.WriteClassName);
输出结果为
{"@type":"[O", "@value":"[1,2,3]"}
这会导致反序列化失败或结果错误

Summary of your change

ObjectReaderImplObject第106行应判断contextClass是否为null,为null时不更改autoTypeObjectReader类型

Please indicate you've done the following:

  • Made sure tests are passing and test coverage is added if needed.
  • Made sure commit message follow the rule of Conventional Commits specification.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed.

@CLAassistant
Copy link

CLAassistant commented Dec 22, 2024

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
0 out of 2 committers have signed the CLA.

❌ ra1nz
❌ zhengshiyu1


zhengshiyu1 seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@wenshao
Copy link
Member

wenshao commented Dec 22, 2024

请签署CLA

@ra1nz
Copy link
Contributor Author

ra1nz commented Dec 22, 2024

请签署CLA

已在cla-assistant.io完成签署

@wenshao
Copy link
Member

wenshao commented Dec 22, 2024

请在本地执行mvn validate修复codestyle相关的问题

@ra1nz
Copy link
Contributor Author

ra1nz commented Dec 22, 2024

请在本地执行mvn validate修复codestyle相关的问题

已修复

@wenshao wenshao merged commit a424be0 into alibaba:main Dec 22, 2024
12 of 13 checks passed
@wenshao wenshao added the bug Something isn't working label Dec 22, 2024
@wenshao wenshao added this to the 2.0.54 milestone Dec 22, 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants