dssrializer
@JsonComponent implementation, serialize and deserialize JSON on Java/Spring
Create POJO
public class User
Create UserJsonSerializer class
@JsonComponent
public class UserJsonSerializer extends JsonSerializer<User>
And UserJsonDeserializer class
@JsonComponent
public class UserJsonDeserializer extends JsonDeserializer<User>
Automatic registration on ObjectMapper
How use it
@Autowired
private ObjectMapper objectMapper;
//serialize
assertThat(objectMapper.writeValueAsString(user)).contains("dni");
//deserialize
User user = objectMapper.readValue(USER_JSON, User.class);
Test
gradle test