加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

JSONObject 解析

发布时间:2020-12-16 19:15:16 所属栏目:百科 来源:网络整理
导读:之前解析json一直用get的方法,但是如果抛异常会让解析中断很烦人。今天发现了 JSONObject还提供了一个更好用的方法opt。看来以后文档还是要更加认真的读的,下面是文档中的原文。 A JSONObject constructor can be used to convert an external form JSON t

之前解析json一直用get的方法,但是如果抛异常会让解析中断很烦人。今天发现了JSONObject还提供了一个更好用的方法opt。看来以后文档还是要更加认真的读的,下面是文档中的原文。

A JSONObject constructor can be used to convert an external form JSON text into an internal form whose values can be retrieved with thegetandoptmethods,or to convert values into a JSON text using theputandtoStringmethods. Agetmethod returns a value if one can be found,and throws an exception if one cannot be found. Anoptmethod returns a default value instead of throwing an exception,and so is useful for obtaining optional values.

详见:http://www.json.org/javadoc/org/json/JSONObject.html

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读