JSONObjecy的key存在值得时候,两者是没有什么区别的,然后如果key对应的value为null,那么getString方法就会报错。
原因:
我们可以看一下getString的源码。
public String getString( String key ) {
verifyIsNull();
Object o = get( key );
if( o != null ){
return o.toString();
}
throw new JSONException( "JSONObject[" + JSONUtils.quote( key ) + "] not found." );
}