This repository was archived by the owner on Oct 23, 2024. It is now read-only.
Fix issue2736(JSONObject.keySet()中可能包含非String键)#2748
Merged
wenshao merged 2 commits intoalibaba:masterfrom Sep 19, 2019
Merged
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2748 +/- ##
============================================
- Coverage 80.12% 80.11% -0.02%
- Complexity 7068 7071 +3
============================================
Files 145 145
Lines 26708 26709 +1
Branches 6374 6374
============================================
- Hits 21400 21398 -2
- Misses 3473 3478 +5
+ Partials 1835 1833 -2
Continue to review full report at Codecov.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix #2736
JSONObject.innerMap的泛型参数为<String, Object>,而DefaultJSONParser.parseObject()方法中的map没有指定泛型参数,往里put键值对也没有做类型检查,可能会put进非String类型的key。当前的
parseObject()逻辑中如果开启了NonStringKeyAsString这个特性,则会将key转为String类型。可以直接在这个判断条件后面新增一个对JSONObject的判断。The parameterType of
JSONObject.innerMapis <String, Object>, while in the methodDefaultJSONParser.parseObject(), non-String key might be put into this map, resulting in unexpected outcome.Currently, the type of key will be converted to String only when the feature
NonStringKeyAsStringis enabled. Therefore, an additional statement which determines whether current object is a JSONObject can be added after that to suit the case here.