工作筆記(在不知道json的key時(shí)如何獲取當(dāng)前json的keys)
String json="{'name':'angui','age':'23','like':'吃水果'}"; JSONObject j = JSON.parseObject(json); j.remove("age"); System.out.println(json.toString()); System.out.println(j.toJSONString()); //將json轉(zhuǎn)換為key=value&key=value&...的形式 StringBuilder sb = new StringBuilder(); String sbString=""; try { org.json.JSONObject jsonObject = new org.json.JSONObject(json); Iterator iterator = jsonObject.keys(); while(iterator.hasNext()){ String key = (String) iterator.next(); sb.append("&"+key); sb.append("="+jsonObject.getString(key)); } sb.append("&key"); sbString = sb.substring(1); } catch (JSONException e) { e.printStackTrace(); } System.out.println(sbString);
網(wǎng)站欄目:java中獲取json的所有key方法-創(chuàng)新互聯(lián)
網(wǎng)頁(yè)鏈接:http://www.rwnh.cn/article40/dospho.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)頁(yè)設(shè)計(jì)公司、關(guān)鍵詞優(yōu)化、做網(wǎng)站、響應(yīng)式網(wǎng)站、移動(dòng)網(wǎng)站建設(shè)、網(wǎng)站導(dǎo)航
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)