在JSON解析中会遇到一种错误,很常见的错误:org.json.JSONException: No value for thumbnail_pic
是因为我们解析方法getString(" ")是因为JSON里面不存在这个value,
我们可以用另外一个方法optString(" ")这个方法如果不存在value会返回" "空字符串,不会 报异常。
为了安全起见一般都是用optString方法,不知道性能上有什么区别,知道的朋友麻烦说一下。
参考原文:http://blog.csdn.net/java2009cgh/article/details/8277178