JSONObject 解析

之前解析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 the get and opt methods, or to convert values into a JSON text using the put and toString methods. A get method returns a value if one can be found, and throws an exception if one cannot be found. An opt method 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

JSONObject 解析,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。