jsonObject.has()是干嘛的?
String jsonStr=new String(data); try { JSONObject jsonObject=new JSONObject(jsonStr); if (jsonObject.has("fileUri")){ } } catch (JSONException e) { e.printStackTrace(); }
擁有18年軟件開發(fā)和IT教學(xué)經(jīng)驗(yàn)。曾任多家上市公司技術(shù)總監(jiān)、架構(gòu)師、項(xiàng)目經(jīng)理、高級軟件工程師等職務(wù)。 網(wǎng)絡(luò)人氣名人講師,...
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(); ????}
可以看出是通過使用Map.containsKey(key)方法來做出判斷的。