I am trying to make annotation in spring boot project. I want to use this annotation for multiple methods which has got different type of request body model classes. But I have to convert request bodies to general object. Because I can't predict type of object before.
By the way I will take only one field which is "username" from any object. Every object have "username" field but classes are different.
Map<String, Object> map = new HashMap<>();
final ObjectMapper mapper = new ObjectMapper();
final Object pojo = mapper.convertValue(map, Object.class);
String username = pojo.getUsername();