首页 > 编程 > Java > 正文

【JAVA-工具类】list转json

2019-11-08 20:26:30
字体:
来源:转载
供稿:网友
    public void writerJson(List<Object> list) {        String json = JSONArray.toJSONString(list);        HttpServletResponse response = getResponse();        response.setContentType("application/json;charset=utf-8");        PRintWriter out = null;        try {            out = response.getWriter();            out.write(json);        } catch (IOException e) {            logger.error("BaseAction::writerJson catch exception:",e);        } finally {            if (out != null)                out.close();        }    }
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表