use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project jackson-databind by FasterXML.
the class TestJDKSerialization method testObjectReader.
public void testObjectReader() throws IOException {
ObjectReader origReader = MAPPER.readerFor(MyPojo.class);
String JSON = "{\"x\":1,\"y\":2}";
MyPojo p1 = origReader.readValue(JSON);
assertEquals(2, p1.y);
ObjectReader anyReader = MAPPER.readerFor(AnyBean.class);
AnyBean any = anyReader.readValue(JSON);
assertEquals(Integer.valueOf(2), any.properties().get("y"));
byte[] readerBytes = jdkSerialize(origReader);
ObjectReader reader2 = jdkDeserialize(readerBytes);
MyPojo p2 = reader2.readValue(JSON);
assertEquals(2, p2.y);
ObjectReader anyReader2 = jdkDeserialize(jdkSerialize(anyReader));
AnyBean any2 = anyReader2.readValue(JSON);
assertEquals(Integer.valueOf(2), any2.properties().get("y"));
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project jackson-databind by FasterXML.
the class EnumAltIdTest method testEnumDesIgnoringCaseWithUpperCaseToString.
public void testEnumDesIgnoringCaseWithUpperCaseToString() throws IOException {
ObjectReader r = MAPPER.readerFor(LowerCaseEnum.class).with(DeserializationFeature.READ_ENUMS_USING_TO_STRING, DeserializationFeature.READ_ENUMS_IGNORING_CASE);
assertEquals(LowerCaseEnum.A, r.readValue("\"A\""));
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project jackson-databind by FasterXML.
the class EnumAltIdTest method testIgnoreCaseInEnumSet.
public void testIgnoreCaseInEnumSet() throws IOException {
ObjectReader r = READER_IGNORE_CASE.forType(new TypeReference<EnumSet<TestEnum>>() {
});
EnumSet<TestEnum> set = r.readValue("[\"jackson\"]");
assertEquals(1, set.size());
assertTrue(set.contains(TestEnum.JACKSON));
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project jackson-databind by FasterXML.
the class TestPOJOAsArrayWithBuilder method testWithCreatorAndView.
public void testWithCreatorAndView() throws Exception {
ObjectReader reader = MAPPER.readerFor(CreatorValue.class);
CreatorValue value;
// First including values in view
value = reader.withView(String.class).readValue("[1,2,3]");
assertEquals(1, value.a);
assertEquals(2, value.b);
assertEquals(3, value.c);
// then not including view
value = reader.withView(Character.class).readValue("[1,2,3]");
assertEquals(1, value.a);
assertEquals(2, value.b);
assertEquals(0, value.c);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project camel by apache.
the class RestErrorTest method shouldDeserializeFromJson.
@Test
public void shouldDeserializeFromJson() throws Exception {
final ObjectMapper objectMapper = new ObjectMapper();
final ObjectReader reader = objectMapper.readerFor(RestError.class);
final RestError gotWithErrorCode = reader.<RestError>readValue("{\"errorCode\":\"errorCode\",\"message\":\"message\",\"fields\":[ \"field1\",\"field2\" ]}");
assertEquals(gotWithErrorCode, error);
final RestError gotWithStatusCode = reader.<RestError>readValue("{\"statusCode\":\"errorCode\",\"message\":\"message\",\"fields\":[ \"field1\",\"field2\" ]}");
assertEquals(gotWithStatusCode, error);
}
Aggregations