java将List集合转换成json输出

功能概述:将集合转换成json,传递到前端进行显示

List<Weather> weatherList=new ArraryList<Weather>;

String json=JSON.toJSONString(weatherList);
respone.setCharacterEncoding("utf-8");
respone.setContentType("text/html;charset=UTF-8");
PrintWriter out=response.getWriter();
out.write(json);
out.flush();
out.close();

 

    原文作者:六月星海
    原文地址: https://blog.csdn.net/qq_38039015/article/details/82146199
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞