use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonGenerator in project jvm-serializers by eishay.
the class WriteResultsToJavascript method writeOutputFile.
// ----------------------------------------------------------------------------
// Write output file.
private static void writeOutputFile(File outputFile, List<Entry> entries) throws Exit {
// Write output.
try {
FileOutputStream fout = new FileOutputStream(outputFile);
try {
JsonFactory factory = new JsonFactory();
factory.disable(JsonGenerator.Feature.QUOTE_FIELD_NAMES);
JsonGenerator gen = factory.createGenerator(fout, JsonEncoding.UTF8);
gen.useDefaultPrettyPrinter();
fout.write("var benchmarkResults = ".getBytes("UTF-8"));
writeJavascriptStats(gen, columns, entries);
} finally {
fout.close();
}
} catch (IOException ex) {
throw new Exit(1, "Error writing to output file \"" + outputFile.getPath() + "\": " + ex.getMessage());
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonGenerator in project elasticsearch by elastic.
the class YamlXContentTests method testBigInteger.
public void testBigInteger() throws Exception {
ByteArrayOutputStream os = new ByteArrayOutputStream();
JsonGenerator generator = new YAMLFactory().createGenerator(os);
doTestBigInteger(generator, os);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonGenerator in project hadoop by apache.
the class TestLogInfo method writeDomainLeaveOpen.
private void writeDomainLeaveOpen(TimelineDomain domain, Path logPath) throws IOException {
if (outStreamDomain == null) {
outStreamDomain = PluginStoreTestUtils.createLogFile(logPath, fs);
}
// Write domain uses its own json generator to isolate from entity writers
JsonGenerator jsonGeneratorLocal = new JsonFactory().createGenerator(outStreamDomain);
jsonGeneratorLocal.setPrettyPrinter(new MinimalPrettyPrinter("\n"));
objMapper.writeValue(jsonGeneratorLocal, domain);
outStreamDomain.hflush();
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonGenerator in project buck by facebook.
the class AuditRulesCommand method printRulesToStdout.
private void printRulesToStdout(CommandRunnerParams params, List<Map<String, Object>> rawRules, final Predicate<String> includeType) throws IOException {
Iterable<Map<String, Object>> filteredRules = FluentIterable.from(rawRules).filter(rawRule -> {
String type = (String) rawRule.get(BuckPyFunction.TYPE_PROPERTY_NAME);
return includeType.apply(type);
});
PrintStream stdOut = params.getConsole().getStdOut();
if (json) {
Map<String, Object> rulesKeyedByName = new HashMap<>();
for (Map<String, Object> rawRule : filteredRules) {
String name = (String) rawRule.get("name");
Preconditions.checkNotNull(name);
rulesKeyedByName.put(name, Maps.filterValues(rawRule, v -> shouldInclude(v)));
}
// We create a new JsonGenerator that does not close the stream.
ObjectMapper mapper = params.getObjectMapper();
JsonFactory factory = mapper.getFactory();
try (JsonGenerator generator = factory.createGenerator(stdOut).disable(JsonGenerator.Feature.AUTO_CLOSE_TARGET).useDefaultPrettyPrinter()) {
mapper.writeValue(generator, rulesKeyedByName);
}
stdOut.print('\n');
} else {
for (Map<String, Object> rawRule : filteredRules) {
printRuleAsPythonToStdout(stdOut, rawRule);
}
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonGenerator in project elasticsearch by elastic.
the class CborXContentTests method testBigInteger.
public void testBigInteger() throws Exception {
ByteArrayOutputStream os = new ByteArrayOutputStream();
JsonGenerator generator = new CBORFactory().createGenerator(os);
doTestBigInteger(generator, os);
}
Aggregations