为什么/如何取消选中org.json.JSONException? [英] Why/how is org.json.JSONException unchecked?

查看:109
本文介绍了为什么/如何取消选中org.json.JSONException?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

阅读, JSONException 扩展了 RuntimeException ,因此是未经检查的异常。



您可以在源代码此处。


Reading How to identify checked and unchecked exceptions in java? makes me wonder:

Why is org.json.JSONException unchecked according to maven and eclipse? (no compilation error when not handled)

Both are extending java.lang.Exception according to the javadoc and the source code...


org.JSON.JSONArray produces no error without try/catch:


For comparison, here is a checked exception example:

atg.taglib.json.util.JSONArray produces an error without try/catch:

atg.taglib.json.util.JSONArray produces no error with try/catch:

解决方案

You have an old version of the org.json library. I guess they also haven't updated their doc in a while. Since version 20131018, JSONException extends RuntimeException and is therefore an unchecked exception.

You can see it in the source code, here.

这篇关于为什么/如何取消选中org.json.JSONException?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆