use of org.codehaus.jackson.JsonFactory in project neo4j by neo4j.
the class RowWriterTests method shouldWriteNestedMaps.
@Test
public void shouldWriteNestedMaps() throws Exception {
ByteArrayOutputStream out = new ByteArrayOutputStream();
JsonGenerator json = new JsonFactory(new Neo4jJsonCodec()).createJsonGenerator(out);
JsonNode row = serialize(out, json, new RowWriter());
MatcherAssert.assertThat(row.size(), equalTo(1));
JsonNode firstCell = row.get(0);
MatcherAssert.assertThat(firstCell.get("one").get("two").size(), is(2));
MatcherAssert.assertThat(firstCell.get("one").get("two").get(0).asBoolean(), is(true));
MatcherAssert.assertThat(firstCell.get("one").get("two").get(1).get("three").asInt(), is(42));
}
use of org.codehaus.jackson.JsonFactory in project pinpoint by naver.
the class ObjectMapper_1_x_IT method testConstructor.
@Test
public void testConstructor() throws Exception {
ObjectMapper mapper1 = new ObjectMapper();
ObjectMapper mapper2 = new ObjectMapper(new JsonFactory());
Constructor<?> omConstructor1 = ObjectMapper.class.getConstructor();
Constructor<?> omConstructor2 = ObjectMapper.class.getConstructor(JsonFactory.class);
Constructor<?> omConstructor3 = ObjectMapper.class.getConstructor(JsonFactory.class, SerializerProvider.class, DeserializerProvider.class);
Class<?> serializationConfig = null;
Class<?> deserializationConfig = null;
try {
serializationConfig = Class.forName("org.codehaus.jackson.map.SerializationConfig");
deserializationConfig = Class.forName("org.codehaus.jackson.map.DeserializationConfig");
} catch (ClassNotFoundException ignored) {
}
Constructor<?> omConstructor4 = null;
if (serializationConfig != null && deserializationConfig != null) {
omConstructor4 = ObjectMapper.class.getConstructor(JsonFactory.class, SerializerProvider.class, DeserializerProvider.class, serializationConfig, deserializationConfig);
}
PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
verifier.printCache();
if (omConstructor4 != null) {
verifier.verifyTrace(event(SERVICE_TYPE, omConstructor4));
}
verifier.verifyTrace(event(SERVICE_TYPE, omConstructor3), event(SERVICE_TYPE, omConstructor1));
if (omConstructor4 != null) {
verifier.verifyTrace(event(SERVICE_TYPE, omConstructor4));
}
verifier.verifyTrace(event(SERVICE_TYPE, omConstructor3), event(SERVICE_TYPE, omConstructor2));
verifier.verifyTraceCount(0);
}
use of org.codehaus.jackson.JsonFactory in project zaproxy by zaproxy.
the class HarUtils method createHarRequest.
public static HarRequest createHarRequest(String jsonHarRequest) throws IOException {
HarRequest harRequest;
try (JsonParser jp = new JsonFactory().createJsonParser(jsonHarRequest)) {
jp.nextToken();
jp.nextToken();
harRequest = new HarRequest(jp, null);
}
return harRequest;
}
use of org.codehaus.jackson.JsonFactory in project flink by apache.
the class DumpCompiledPlanTest method dump.
private void dump(Plan p) {
p.setExecutionConfig(new ExecutionConfig());
try {
OptimizedPlan op = compileNoStats(p);
PlanJSONDumpGenerator dumper = new PlanJSONDumpGenerator();
String json = dumper.getOptimizerPlanAsJSON(op);
JsonParser parser = new JsonFactory().createJsonParser(json);
while (parser.nextToken() != null) ;
} catch (JsonParseException e) {
e.printStackTrace();
Assert.fail("JSON Generator produced malformatted output: " + e.getMessage());
} catch (Exception e) {
e.printStackTrace();
Assert.fail("An error occurred in the test: " + e.getMessage());
}
}
use of org.codehaus.jackson.JsonFactory in project stanbol by apache.
the class AnalyzedTextSerializer method serialize.
/**
* Serializes the parsed {@link AnalysedText} to the {@link OutputStream} by
* using the {@link Charset}.
* @param at the {@link AnalysedText} to serialize
* @param out the {@link OutputStream}
* @param charset the {@link Charset}. UTF-8 is used as default if <code>null</code>
* is parsed
*/
public void serialize(AnalysedText at, OutputStream out, Charset charset) throws IOException {
if (at == null) {
throw new IllegalArgumentException("The parsed AnalysedText MUST NOT be NULL!");
}
if (out == null) {
throw new IllegalArgumentException("The parsed OutputStream MUST NOT be NULL");
}
if (charset == null) {
charset = UTF8;
}
JsonFactory jsonFactory = mapper.getJsonFactory();
JsonGenerator jg = jsonFactory.createJsonGenerator(new OutputStreamWriter(out, charset));
jg.useDefaultPrettyPrinter();
jg.writeStartObject();
jg.writeArrayFieldStart("spans");
jg.writeTree(writeSpan(at));
for (Iterator<Span> it = at.getEnclosed(EnumSet.allOf(SpanTypeEnum.class)); it.hasNext(); ) {
jg.writeTree(writeSpan(it.next()));
}
jg.writeEndArray();
jg.writeEndObject();
jg.close();
}
Aggregations