【文件属性】:
文件名称:JSON中optString和getString方法的区别
文件大小:25KB
文件格式:PDF
更新时间:2021-01-06 01:40:33
IN ng ON
optString方法会在对应的key中的值不存在的时候返回一个空字符串,但是getString会抛一个JSONException 。
/**
* Returns the value mapped by {@code name} if it exists, coercing it if
* necessary, or throws if no such mapping exists.
*
* @throws JSONException if no such mapping exists.
*/
public String getString(String