Skip to content

fix: leave a bean field null for an empty array in fastjson1-compatible tree conversion - #7979

Open
adityaanikam wants to merge 1 commit into
alibaba:mainfrom
adityaanikam:fix-empty-array-bean-7978
Open

adityaanikam wants to merge 1 commit into
alibaba:mainfrom
adityaanikam:fix-empty-array-bean-7978

Conversation

@adityaanikam

Copy link
Copy Markdown
Contributor

What this PR does / why we need it?

Fixes #7978. With {"detail":[]}, JSON.parseObject(body).toJavaObject(Bean.class) created an empty Detail, while stream parsing and fastjson 1.2.83 give null.

Summary of your change

In FieldReader.acceptAny, an empty com.alibaba.fastjson.JSONArray for a bean field is now null. List, Set and array fields stay empty, and native fastjson2 conversion is unchanged. Non-empty arrays are not changed.

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.

Copilot AI balanced review requested due to automatic review settings November 30, 2026 13:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 40.00000% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...java/com/alibaba/fastjson2/reader/FieldReader.java 40.00% 2 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants