色婷婷狠狠18禁久久YY,CHINESE性内射高清国产,国产女人18毛片水真多1,国产AV在线观看

怎么用json轉(zhuǎn)list的集合對(duì)象?

簡(jiǎn)單的手動(dòng)放置鍵值對(duì)到JSONObject,然后在put到JSONArray對(duì)象里L(fēng)ist<Article>al=articleMng.find(f);System.out.println(al.size());HttpServletResponsehsr=ServletActionContext.getResponse();if(null==al){return;}for(Articlea:al){System.out.println(a.getId()+a.getDescription()+a.getTitle());}JSONArrayjson=newJSONArray()

;for(Articlea:al){JSONObjectjo=newJSONObject()

;jo.put("id",a.getId());jo.put("title",a.getTitle())

;jo.put("desc",a.getDescription());json.put(jo);}try{System.out.println(json.toString())

;hsr.setCharacterEncoding("UTF-8")

;hsr.getWriter().write(json.toString());}catch(IOExceptione){e.printStackTrace();}復(fù)制代碼上述代碼JSONArray是引入的org.json.JSONArray包