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

Add a JSONReader.Feature that can convert empty string to null #2321

Merged
merged 3 commits into from
Mar 16, 2024

Conversation

rowstop
Copy link
Contributor

@rowstop rowstop commented Mar 13, 2024

What this PR does / why we need it?

Add a JSONReader.Feature that can convert empty string to null ,for issue #2317 #2060

Summary of your change

需要注意这里的实现,有些集合不支持 null,而且我觉得直接过滤 null 值也合适,我这里直接过滤了,看下这么做否合适
但是动态字节码的逻辑里并没有过滤null值,不太敢改这一块,
FieldReaderStringField
image

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.

@rowstop rowstop changed the title Add a JSONReader.Feature that can convert empty strings to null Add a JSONReader.Feature that can convert empty string to null Mar 13, 2024
@codecov-commenter
Copy link

codecov-commenter commented Mar 13, 2024

Codecov Report

Attention: Patch coverage is 35.29412% with 22 lines in your changes are missing coverage. Please review.

Project coverage is 77.41%. Comparing base (6a1fd00) to head (37e74cd).
Report is 3 commits behind head on main.

Files Patch % Lines
...in/java/com/alibaba/fastjson2/JSONReaderJSONB.java 11.11% 10 Missing and 6 partials ⚠️
...ibaba/fastjson2/reader/FieldReaderStringField.java 0.00% 1 Missing and 2 partials ⚠️
...ain/java/com/alibaba/fastjson2/JSONReaderUTF8.java 0.00% 1 Missing and 1 partial ⚠️
...baba/fastjson2/reader/ObjectReaderImplListStr.java 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2321      +/-   ##
============================================
- Coverage     77.43%   77.41%   -0.02%     
- Complexity    22731    22743      +12     
============================================
  Files           634      634              
  Lines         85225    85256      +31     
  Branches      19322    19337      +15     
============================================
+ Hits          65995    66003       +8     
- Misses        11229    11243      +14     
- Partials       8001     8010       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@wenshao
Copy link
Member

wenshao commented Mar 16, 2024

和其他JSONReader.Feature一致,EmptyStringToNull改为EmptyStringAsNull ?

@rowstop rowstop closed this Mar 16, 2024
@rowstop rowstop reopened this Mar 16, 2024
@rowstop rowstop closed this Mar 16, 2024
@rowstop rowstop reopened this Mar 16, 2024
@rowstop
Copy link
Contributor Author

rowstop commented Mar 16, 2024

和其他JSONReader.Feature一致,EmptyStringToNull改为EmptyStringAsNull ?

好的 看下

@wenshao wenshao merged commit 750a830 into alibaba:main Mar 16, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants