src/org/nutz/json/Json.java
public static void toJson(Writer writer, Object obj, JsonFormat format) {
        try {
            if (format == null)
                format = deft;
            JsonRender jr;
            Class<? extends JsonRender> jrCls = getJsonRenderCls();
            if (jrCls == null)
                jr = new JsonRenderImpl();
            else
            	jr = Mirror.me(jrCls).born();
            jr.setWriter(writer);
            jr.setFormat(format);
            jr.render(obj);

            writer.flush();
        }
        catch (IOException e) {
            throw Lang.wrapThrow(e, JsonException.class);
        }
    }
public static void toJson(Writer writer, Object obj, JsonFormat format) {
        try {
            if (format == null)
                format = deft;
            JsonRender jr;
            Class<? extends JsonRender> jrCls = getJsonRenderCls();
            if (jrCls == null)
                jr = new JsonRenderImpl();
            else
            	jr = Mirror.me(jrCls).born();
            jr.setWriter(writer);
            jr.setFormat(format);
            jr.render(obj);

            writer.flush();
        }
        catch (IOException e) {
            throw Lang.wrapThrow(e, JsonException.class);
        }
    }
将一个 JAVA 对象以 JSON 的形式写到一个文本输出流里，并且可以设定 JSON 字符串的格式化方式

@param writer
文本输出流
@param obj
JAVA 对象
@param format
JSON 字符串格式化方式 ，若 format 为 null ，则以 JsonFormat.nice() 格式输出