Maison > Questions et réponses > le corps du texte
jsonObject.has()是干嘛的?
String jsonStr=new String(data);
try {
JSONObject jsonObject=new JSONObject(jsonStr);
if (jsonObject.has("fileUri")){
}
} catch (JSONException e) {
e.printStackTrace();
}
怪我咯2017-04-18 09:19:18
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>();
}
On peut voir que le jugement est effectué en utilisant la méthode Map.containsKey(key).
怪我咯2017-04-18 09:19:18
Requête si l'objet contient la clé et renvoie un booléen, ce qui est cohérent avec l'utilisation de Map.containsKey(key)