-
Notifications
You must be signed in to change notification settings - Fork 479
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
[FEATURE]建议增加一些空值和空流转换时的容错 #389
Comments
wenshao
added
bug
Something isn't working
and removed
enhancement
New feature or request
labels
May 31, 2022
问题已经修复,请帮忙用2.0.6-SNAPSHOT版本验证,2.0.6正式版预计6月5日前发布 |
好的感谢。
好的感谢。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
请描述您的需求或者改进建议
希望将空字符或者空流转成JSONObject不用报错,而是返回空对象。(2.0.5版本)
请描述你建议的实现方案
一些空值,或者空参数建议不要直接报错,而是返回一个空对象,因为从fastjson迁移到fastjson2时发现一些空参数不能转成JSONObject。
描述您考虑过的替代方案
部分情况下使用parseObject(String text)可以解决空串的问题
附加信息
1.空串转成JSONObject报错(fastjson1.x版本没有问题)。
String whiteConfig = "";
com.alibaba.fastjson2.JSONObject whiteListJson = com.alibaba.fastjson2.JSON.parseObject(whiteConfig, com.alibaba.fastjson2.JSONObject.class);
可以使用parseObject(String text)这个方法,但是最好做一下兼容。
2.使用后的流转换JSONObject报错(fastjson1.x版本没有问题)。
ClassPathResource jsoupWhiteListPathRes = new ClassPathResource("/json/xxx.json");
InputStream whiteConfig = jsoupWhiteListPathRes.getInputStream();
com.alibaba.fastjson2.JSONObject whiteListJson2 = com.alibaba.fastjson2.JSON.parseObject(whiteConfig);
com.alibaba.fastjson2.JSONObject whiteListJson3 = com.alibaba.fastjson2.JSON.parseObject(whiteConfig);
The text was updated successfully, but these errors were encountered: