JSONObject中optString和getString等的区别
2017-06-03 14:29
387 查看
The difference is that
it's an error for the data to be missing, or
简单来说就是optString会在得不到你想要的值时候返回空字符串”“,而getString会抛出异常。至此,疑惑已经解除。
optStringreturns the empty string (
"") if the key you specify doesn't exist.
getStringon the other hand throws a
JSONException. Use
getStringif
it's an error for the data to be missing, or
optStringif you're not sure if it will be there.
简单来说就是optString会在得不到你想要的值时候返回空字符串”“,而getString会抛出异常。至此,疑惑已经解除。
相关文章推荐
- JSONObject中optString和getString等的区别
- 关于JSON中optString和getString的区别
- JSON中optString和getString的区别
- JSON中optString和getString的区别
- getString和optString的区别(补充toString和valueOf)
- Json中optString和getString的区别
- (转)Field getField(String name)与Field getDeclaredField(String name)的区别
- istream::get,getline函数与string getline区别 istream::read 和ostream::write
- ASP.NET中Get和Post的用法 Request.QueryString,Request.Form,Request.Params的区别
- istream::get,getline函数与string getline区别 istream::read 和ostream::write
- c++ string getline()函数 istream::get,getline函数与string getline区别 istream::read 和ostream::write
- ASP.NET中Get和Post的用法 Request.QueryString,Request.Form,Request.Params的区别
- ASP.NET中Get和Post的用法 Request.QueryString,Request.Form,Request.Params的区别 [转]
- Dom4j中getText()和getStringValue()的作用和区别。
- ASP.NET中Get和Post的用法 Request.QueryString,Request.Form,Request.Params的区别
- ASP.NET中Get和Post的用法 Request.QueryString,Request.Form,Request.Params的区别 [转]
- ASP.NET中Get和Post的用法 Request.QueryString,Request.Form,Request.Params的区别
- ASP.NET中Get和Post的用法 Request.QueryString,Request.Form,Request.Params的区别 [转]
- istream::get,getline函数与string getline区别 istream::read 和ostream::write
- javax.servlet.ServletRequest 的getAttribute(String name)与getParmeter(String name)的区别