import com.fasterxml.jackson.core.JsonEncoding;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerator;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
public class JsonGeneratorDemo {
@Test
public void test() throws IOException {
JsonFactory factory = new JsonFactory();
JsonGenerator generator = factory.createGenerator(
new File("src/data/output.json"), JsonEncoding.UTF8);
generator.writeStartObject();
generator.writeStringField("brand", "Mercedes");
generator.writeNumberField("doors", 6);
generator.writeEndObject();
generator.close();
}
}