jsonObject.has()是干嘛的? String jsonStr=new String(data); try { JSONObject jsonObject=new JSONObject(jsonStr); if (jsonObject.has("fileUri")){ } } catch (JSONException e) { e.printStackTrace(); }
4 回答

倚天杖
TA贡献1828条经验 获得超3个赞
Determine if the JSONObject contains a specific key.
Parameters:
key A key string.
Returns:
true if the key exists in the JSONObject.
public boolean has(String key) {
return this.map.containsKey(key);
}
public JSONObject() {
this.map = new HashMap<String, Object>();
}
可以看出是通过使用Map.containsKey(key)方法来做出判断的。
添加回答
举报
0/150
提交
取消