issue #1780 (支持org.json.JSONObject )的两种解决方案 #2702
Merged
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.
关于issue #1780,感觉有两个思路
fastjson内部支持org.json.JSONObject序列化,添加相应的Codec,涉及的文件有:
pom.xml
src/main/java/com/alibaba/fastjson/serializer/JSONObjectCodec.java
src/main/java/com/alibaba/fastjson/serializer/SerializeConfig.java
测试用例是:
src/test/java/com/alibaba/json/bvt/issue_1700/Issue1780_JSONObject.java
使用现有的
Module
功能来自定义解析器,而不是框架去兼容,只要修改:pom.xml
添加 org.json.JSONObject支持使用示例是:
src/test/java/com/alibaba/json/bvt/issue_1700/Issue1780_Module.java
个人建议这种特殊场景让用户自定义就好了,采用方案二 0-0
@wenshao PTAL