title: Generic function json to POJO?
body: <p>I am converting my json string to POJO using jackson <code>ObjectMapper</code></p>
  
  <pre><code>objectMapper.readValue(jsonString, ResourceTypes.getClassName(resourceType))
  </code></pre>
  
  <p><code>ResourceTypes.getClassName(resourceType)</code> returns different class names.</p>
  
  <p>Ex: Student.class, Hotel.class, etc</p>
  
  <p>Now I wanted to write a generic function for this like:</p>
  
  <pre><code>public static T toPOJO(String json, Class&lt;T&gt; type){
  
  
          try {
  
              return JSON_MAPPER.readValue(json, type);
  
          } catch (JsonParseException e) {
              e.printStackTrace();
          } catch (JsonMappingException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
          return null;
      }
  </code></pre>
  
  <p>However this gives error unknown type <code>T</code>. How to write this function to return any POJO?</p>