Is there a way I can make the static method toObject generic by passing the T class and return type T?
public class JsonUtil { private JsonUtil() { } public static Object toObject(String jsonString, Class clazz, boolean unwrapRootValue) throws TechnicalException { ObjectMapper mapper = new ObjectMapper(); mapper.writerWithDefaultPrettyPrinter(); if (unwrapRootValue) mapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE); try { return mapper.readValue(jsonString, clazz); } catch (IOException e) { throw new TechnicalException("Exception while converting JSON to Object", e); } } }