Map转Json

       Map map = new HashMap();
        map.put("success", "true");
        map.put("photoList", photoList);
        map.put("currentUser", "zhang");
        
        //net.sf.json.JSONObject 将Map转换为JSON方法
        JSONObject json = JSONObject.fromObject(map);

        //org.json.JSONObject 将Map转换为JSON方法
        JSONObject json =new JSONObject(map);

 

文章引用:https://www.cnblogs.com/sere/p/4627536.html

posted @ 2019-01-03 11:03  anliex  阅读(9)  评论(0)    收藏  举报