private final JsonFactory factory = new JsonFactory();
private final JsonGenerator gen;
public JsonWriter(OutputStream out, boolean pretty) throws IOException{
JsonGenerator writer = factory.createJsonGenerator(out);
gen = pretty ? writer.useDefaultPrettyPrinter() : writer;
}
public void write(FieldReader reader) throws JsonGenerationException, IOException{
writeValue(reader);
gen.flush();