package org.well.well.core.util;

import org.well.well.core.mapper.JsonMapper;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created by phantomli on 2016/2/17.
 */
public class JsonTool {
    public static void writeDataResult(Object object,HttpServletResponse response) throws IOException {
        JsonMapper jsonMapper = new JsonMapper();
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html; charset=utf-8");
        PrintWriter writer = response.getWriter();
        System.out.println(jsonMapper.toJson(object));
        writer.write(jsonMapper.toJson(object));
        writer.flush();
        writer.close();
    }

}
