JSONObject optString与getString

来源:互联网 发布:淘宝店的粉丝是什么 编辑:程序博客网 时间:2024/04/25 14:39

1.getString(String name)与optString(String name),功能一样,只是当无返回值时,getString(String name)抛出错误,optString(String name)返回空值

   getString(String name)

  Returns the value mapped by name if it exists, coercing it if necessary, or throws if no such mapping exists.


   optString(String name)

  Returns the value mapped by name if it exists, coercing it if necessary, or the empty string if no such mapping exists.

2 0
原创粉丝点击