list转JSONArray

  sre

5fdebad0dd4b88450.jpg_fo742.jpg

public class test {
    public  static JSONArray   ListToJSONArray() {
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();

        Map<String, Object> map1 = new HashMap<String, Object>();
        map1.put("id", "jianzhu07");
        map1.put("title", "建筑");
        map1.put("name", "jianzhu07");
        map1.put("img_num", "10");
        map1.put("img_src", "https://img-cdn-qiniu.dcloud.net.cn/tuku/img/jianzhu07.jpg");

        Map<String, Object> map2 = new HashMap<String, Object>();
        map2.put("id", "dongwu09");
        map2.put("title", "动物");
        map2.put("name", "dongwu09");
        map2.put("img_num", "10");
        map2.put("img_src", "https://img-cdn-qiniu.dcloud.net.cn/tuku/img/dongwu09.jpg");


        return JSONArray.parseArray(JSON.toJSONString(list));

    }

}

LEAVE A COMMENT

Captcha Code