Fastjson writeJSONString
Fastjson writeJSONString 메서드
Fastjson 버전 1.2.11에서는 JSON 클래스에 OutputStream/Writer에 대한 직접 지원이 추가되었습니다.
package com.alibaba.fastjson; public abstract class JSON { public static final int writeJSONString(OutputStream os, // Object object, // SerializerFeature... features) throws IOException; public static final int writeJSONString(OutputStream os, // Charset charset, // Object object, // SerializerFeature... features) throws IOException; public static final int writeJSONString(Writer os, // Object object, // SerializerFeature... features) throws IOException; }
Sample
import com.alibaba.fastjson;
import java.nio.charset.Charset;
class Model {
public int value;
}
Model 모델 = 신규( ) ;
model.value = 1001;
OutputStream os = ...;
JSON.writeJSONString(os, 모델);
JSON.writeJSONString(os, Charset.from("GB18030"), 모델);
작성기 작가 = ...;
JSON.writeJSONString(os, 모델);