use of org.springframework.boot.jackson.NameAndAgeJsonComponent.Deserializer in project spring-boot by spring-projects.
the class JsonObjectDeserializerTests method deserializeObjectShouldReadJson.
@Test
public void deserializeObjectShouldReadJson() throws Exception {
Deserializer deserializer = new NameAndAgeJsonComponent.Deserializer();
SimpleModule module = new SimpleModule();
module.addDeserializer(NameAndAge.class, deserializer);
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(module);
NameAndAge nameAndAge = mapper.readValue("{\"name\":\"spring\",\"age\":100}", NameAndAge.class);
assertThat(nameAndAge.getName()).isEqualTo("spring");
assertThat(nameAndAge.getAge()).isEqualTo(100);
}
Aggregations