List of usage examples for com.fasterxml.jackson.core JsonEncoding UTF8
JsonEncoding UTF8
To view the source code for com.fasterxml.jackson.core JsonEncoding UTF8.
Click Source Link
From source file:com.proofpoint.event.client.TestJsonEventSerializer.java
@Test public void testEventSerializer() throws Exception { JsonEventSerializer eventSerializer = new JsonEventSerializer(new NodeInfo("test"), FixedDummyEventClass.class); ByteArrayOutputStream out = new ByteArrayOutputStream(); JsonGenerator jsonGenerator = new JsonFactory().createGenerator(out, JsonEncoding.UTF8); FixedDummyEventClass event = TestingUtils.getEvents().get(0); eventSerializer.serialize(event, "sample-trace-token", jsonGenerator); String json = out.toString(Charsets.UTF_8.name()); assertEquals(json, TestingUtils.getNormalizedJson("event.json")); }
From source file:com.sdl.odata.renderer.json.util.JsonWriterUtilTest.java
@Test public void testWritePrimitiveValues() throws Exception { ByteArrayOutputStream stream = new ByteArrayOutputStream(); JsonGenerator jsonGenerator = new JsonFactory().createGenerator(stream, JsonEncoding.UTF8); jsonGenerator.writeStartObject();/*from w ww. j av a 2 s .c om*/ appendPrimitiveValue("MyString", "Some text", jsonGenerator); appendPrimitiveValue("MyByteProperty", Byte.MAX_VALUE, jsonGenerator); appendPrimitiveValue("MyShortProperty", (short) 1, jsonGenerator); appendPrimitiveValue("MyIntegerProperty", 2, jsonGenerator); appendPrimitiveValue("MyFloatProperty", 3.0f, jsonGenerator); appendPrimitiveValue("MyDoubleProperty", 4.0d, jsonGenerator); appendPrimitiveValue("MyLongProperty", (long) 5, jsonGenerator); appendPrimitiveValue("MyBooleanProperty", true, jsonGenerator); appendPrimitiveValue("MyUUIDProperty", UUID.fromString("23492a5b-c4f1-4a50-b7a5-d8ebd6067902"), jsonGenerator); appendPrimitiveValue("DecimalValueProperty", BigDecimal.valueOf(21), jsonGenerator); jsonGenerator.writeEndObject(); jsonGenerator.close(); assertEquals(prettyPrintJson(readContent(EXPECTED_PRIMITIVE_VALUES_PATH)), prettyPrintJson(stream.toString())); }
From source file:org.bin01.db.verifier.JsonEventClient.java
@Override public <T> void postEvent(T event) throws IOException { try {//from ww w . j a v a 2 s .co m ByteArrayOutputStream buffer = new ByteArrayOutputStream(); JsonGenerator generator = factory.createGenerator(buffer, JsonEncoding.UTF8); serializer.serialize(event, generator); out.println(buffer.toString().trim()); } catch (IOException e) { throw Throwables.propagate(e); } }
From source file:org.example.testcases.BasicTypesSerializer.java
public void serialize(File targetFile, BasicTypes basicTypes) throws IOException { try (JsonGenerator jg = jsonFactory.createGenerator(targetFile, JsonEncoding.UTF8)) { writeObject(jg, basicTypes);//from w ww .ja va 2 s .c o m } }
From source file:org.apache.drill.exec.ref.rse.JSONDataWriter.java
public JSONDataWriter(OutputStream out) throws IOException { JsonFactory f = new JsonFactory(); this.g = f.createJsonGenerator(out, JsonEncoding.UTF8); this.g.useDefaultPrettyPrinter(); }
From source file:org.example.testcases.BasicTypeArraysSerializer.java
public void serialize(File targetFile, BasicTypeArrays basicTypeArrays) throws IOException { try (JsonGenerator jg = jsonFactory.createGenerator(targetFile, JsonEncoding.UTF8)) { writeObject(jg, basicTypeArrays); }//from ww w . ja v a2s .co m }
From source file:jvmoptions.OptionAnalyzer.java
static Path toJson(String java6, String java7, String java8) throws Exception { Map<String, Map<String, String>> map6 = makeMap(java6); Map<String, Map<String, String>> map7 = makeMap(java7); Map<String, Map<String, String>> map8 = makeMap(java8); Path output = Paths.get("result", filename("json")); JsonFactory factory = new JsonFactory(); JsonGenerator jg = factory.createGenerator(output.toFile(), JsonEncoding.UTF8).useDefaultPrettyPrinter(); jg.writeStartObject();/* w w w. j a v a 2 s . co m*/ Stream.of(map6, map7, map8).map(Map::keySet).flatMap(Collection::stream).sorted().distinct().forEach(k -> { try { jg.writeFieldName(k); jg.writeStartObject(); Map<String, String> base = pick(k, map8, map7, map6); jg.writeStringField("kind", base.get("kind")); jg.writeStringField("type", base.get("type")); jg.writeStringField("description", base.get("description")); jg.writeStringField("file", base.get("file")); write(jg, "java6", map6.get(k)); write(jg, "java7", map7.get(k)); write(jg, "java8", map8.get(k)); jg.writeEndObject(); } catch (IOException e) { throw new UncheckedIOException(e); } }); jg.writeEndObject(); jg.close(); return output; }
From source file:org.apache.olingo.server.core.debug.AbstractDebugTabTest.java
protected String createJson(DebugTab requestTab) throws IOException { CircleStreamBuffer csb = new CircleStreamBuffer(); JsonGenerator gen = new JsonFactory().createGenerator(csb.getOutputStream(), JsonEncoding.UTF8); requestTab.appendJson(gen);/*from w w w. j a v a2s . c o m*/ gen.flush(); gen.close(); csb.closeWrite(); return IOUtils.toString(csb.getInputStream()); }
From source file:net.echinopsii.ariane.community.core.directory.wat.json.ds.organisational.EnvironmentJSON.java
public final static void oneEnvironment2JSON(Environment environment, ByteArrayOutputStream outStream) throws IOException { JsonGenerator jgenerator = DirectoryBootstrap.getjFactory().createGenerator(outStream, JsonEncoding.UTF8); EnvironmentJSON.environment2JSON(environment, jgenerator); jgenerator.close();//from w ww . j ava 2 s . com }
From source file:net.echinopsii.ariane.community.plugin.rabbitmq.directory.json.RabbitmqClusterJSON.java
public final static void oneRabbitmqCluster2JSON(RabbitmqCluster cluster, ByteArrayOutputStream outStream) throws IOException { JsonGenerator jgenerator = RabbitmqDirectoryBootstrap.getjFactory().createGenerator(outStream, JsonEncoding.UTF8); rabbitmqCluster2JSON(cluster, jgenerator); jgenerator.close();//from w w w. ja v a2 s. c om }