use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project camel by apache.
the class SObjectTreeResponseTest method shouldDeserializeJsonFromSalesforceFailureExample.
@Test
public void shouldDeserializeJsonFromSalesforceFailureExample() throws Exception {
final String json = //
"{\n" + //
" \"hasErrors\" : true,\n" + //
" \"results\" : [{\n" + //
" \"referenceId\" : \"ref2\",\n" + //
" \"errors\" : [{\n" + //
" \"statusCode\" : \"INVALID_EMAIL_ADDRESS\",\n" + //
" \"message\" : \"Email: invalid email address: 123\",\n" + //
" \"fields\" : [ \"Email\" ]\n" + //
" }]\n" + //
" }]\n" + "}";
final ObjectMapper mapper = new ObjectMapper();
final ObjectReader reader = mapper.readerFor(SObjectTreeResponse.class);
final SObjectTreeResponse response = reader.readValue(json);
assertNotNull("Response should be parsed", response);
assertTrue("`hasErrors` flag should be true", response.hasErrors());
assertEquals("Should read one reference", 1, response.getResults().size());
assertThat("The reference should be read as expected", response.getResults(), hasItems(new ReferenceId("ref2", null, Arrays.asList(new RestError("INVALID_EMAIL_ADDRESS", "Email: invalid email address: 123", Arrays.asList("Email"))))));
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project midpoint by Evolveum.
the class JsonValueParser method asDomElement.
Element asDomElement() throws IOException {
ObjectMapper mapper = (ObjectMapper) parser.getCodec();
ObjectReader r = mapper.readerFor(Document.class);
return ((Document) r.readValue(node)).getDocumentElement();
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project midpoint by Evolveum.
the class JsonValueParser method parse.
@Override
public T parse(QName typeName, XNodeProcessorEvaluationMode mode) throws SchemaException {
ObjectMapper mapper = (ObjectMapper) parser.getCodec();
Class clazz = XsdTypeMapper.toJavaType(typeName);
ObjectReader r = mapper.readerFor(clazz);
try {
return r.readValue(node);
// TODO implement COMPAT mode
} catch (IOException e) {
throw new SchemaException("Cannot parse value: " + e.getMessage(), e);
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project JMRI by JMRI.
the class JsonServer method handleClient.
// Handle communication to a client through inStream and outStream
@Override
public void handleClient(DataInputStream inStream, DataOutputStream outStream) throws IOException {
ObjectReader reader = this.mapper.reader();
JsonClientHandler handler = new JsonClientHandler(new JsonConnection(outStream));
// Start by sending a welcome message
handler.onMessage(JsonClientHandler.HELLO_MSG);
while (true) {
try {
handler.onMessage(reader.readTree((InputStream) inStream));
// Read the command from the client
} catch (IOException e) {
// attempt to close the connection and throw the exception
handler.dispose();
throw e;
} catch (NoSuchElementException nse) {
// so break out of the loop
break;
}
}
handler.dispose();
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project logging-log4j2 by apache.
the class LevelMixInTest method testContainer.
@Test
public void testContainer() throws IOException {
final Fixture expected = new Fixture();
final String str = writer.writeValueAsString(expected);
Assert.assertTrue(str.contains("DEBUG"));
final ObjectReader fixtureReader = log4jObjectMapper.readerFor(Fixture.class);
final Fixture actual = fixtureReader.readValue(str);
Assert.assertEquals(expected, actual);
}
Aggregations