import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.Map;
public class MapToObjectConverter {
public static <T> T convert(Map<String, Object> map, Class<T> clazz) throws Exception {
ObjectMapper mapper = new ObjectMapper();
return mapper.convertValue(map, clazz);
}
public static void main(String[] args) throws Exception {
Map<String, Object> map = Map.of(
"name", "Alice",
"age", 30,
"email", "alice@example.com"
);
Person person = convert(map, Person.class);
System.out.println(person);
}
}