use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonParser in project jackson-core by FasterXML.
the class TestJDKSerializability method _copyJson.
protected void _copyJson(JsonFactory f, String json, JsonGenerator g) throws IOException {
JsonParser p = f.createParser(json);
while (p.nextToken() != null) {
g.copyCurrentEvent(p);
}
p.close();
g.close();
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonParser in project jackson-core by FasterXML.
the class TestJDKSerializability method testParseException.
public void testParseException() throws Exception {
JsonFactory jf = new JsonFactory();
JsonParser p = jf.createParser(" { garbage! }");
JsonParseException exc = null;
try {
p.nextToken();
p.nextToken();
fail("Should not get here");
} catch (JsonParseException e) {
exc = e;
}
p.close();
byte[] stuff = jdkSerialize(exc);
JsonParseException result = jdkDeserialize(stuff);
assertNotNull(result);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonParser in project jackson-databind by FasterXML.
the class ExceptionSerializationTest method testSimpleOther.
// to double-check [databind#1413]
public void testSimpleOther() throws Exception {
JsonParser p = MAPPER.getFactory().createParser("{ }");
InvalidFormatException exc = InvalidFormatException.from(p, "Test", getClass(), String.class);
String json = MAPPER.writeValueAsString(exc);
p.close();
assertNotNull(json);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonParser in project beam by apache.
the class TestPipeline method convertToArgs.
public static String[] convertToArgs(PipelineOptions options) {
try {
byte[] opts = MAPPER.writeValueAsBytes(options);
JsonParser jsonParser = MAPPER.getFactory().createParser(opts);
TreeNode node = jsonParser.readValueAsTree();
ObjectNode optsNode = (ObjectNode) node.get("options");
ArrayList<String> optArrayList = new ArrayList<>();
Iterator<Entry<String, JsonNode>> entries = optsNode.fields();
while (entries.hasNext()) {
Entry<String, JsonNode> entry = entries.next();
if (entry.getValue().isNull()) {
continue;
} else if (entry.getValue().isTextual()) {
optArrayList.add("--" + entry.getKey() + "=" + entry.getValue().asText());
} else {
optArrayList.add("--" + entry.getKey() + "=" + entry.getValue());
}
}
return optArrayList.toArray(new String[optArrayList.size()]);
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonParser in project buck by facebook.
the class JsonMatcher method matchesSafely.
@Override
protected boolean matchesSafely(String actualJson, Description description) {
try {
JsonFactory factory = MAPPER.getFactory();
JsonParser jsonParser = factory.createParser(String.format(expectedJson));
JsonNode expectedObject = MAPPER.readTree(jsonParser);
jsonParser = factory.createParser(actualJson);
JsonNode actualObject = MAPPER.readTree(jsonParser);
if (!matchJsonObjects("/", expectedObject, actualObject, description)) {
description.appendText(String.format(" in <%s>", actualJson));
return false;
}
} catch (IOException e) {
description.appendText(String.format("could not parse the following into a json object: <%s>", actualJson));
return false;
}
return true;
}
Aggregations