为了账号安全,请及时绑定邮箱和手机立即绑定

jsonObject.has()是干嘛的?

jsonObject.has()是干嘛的?

翻过高山走不出你 2019-03-13 18:14:23
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)方法来做出判断的。


查看完整回答
反对 回复 2019-04-19
?
慕标琳琳

TA贡献1830条经验 获得超9个赞

https://img1.sycdn.imooc.com//5cb97eca0001319705250131.jpg

查看完整回答
反对 回复 2019-04-19
?
茅侃侃

TA贡献1842条经验 获得超21个赞

判断类中是否有某个字段


查看完整回答
反对 回复 2019-04-19
?
慕田峪7331174

TA贡献1828条经验 获得超13个赞

查询对象是否包含该key,返回boolean,与Map.containsKey(key)用法一致


查看完整回答
反对 回复 2019-04-19
  • 4 回答
  • 0 关注
  • 3290 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号