java - jsonObject.has()是干嘛的?
高洛峰
高洛峰 2017-04-18 09:17:18
0
4
579

jsonObject.has()是干嘛的?

  String jsonStr=new String(data);
        try {
            JSONObject jsonObject=new JSONObject(jsonStr);

            if (jsonObject.has("fileUri")){
            }


        } catch (JSONException e) {
            e.printStackTrace();
        }
高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

répondre à tous(4)
刘奇
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).

洪涛

巴扎黑

Déterminer s'il y a un certain champ dans la classe

刘奇

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)

Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal