title: How to make object return generic
body: <p>I am looking at the following Gson library provided by google. In a tutorial I am following I have found the following code snippet;</p>
  
  <pre><code>public class JsonToJava {
  
      public static void main(String[] args) throws IOException {
          try(Reader reader = new InputStreamReader(JsonToJava.class.getResourceAsStream("/Server1.json"), "UTF-8")){
              Gson gson = new GsonBuilder().create();
              Person p = gson.fromJson(reader, Person.class);
              System.out.println(p);
          }
      }
  }
  </code></pre>
  
  <p>Is it possible to make this generic, for example, if you have the following parameters</p>
  
  <pre><code>public Object getObjectFromJSONString(String jsonString, Class classType){
  </code></pre>
  
  <p>Then we know the class type, is it possible to return any object type or would I have to have individual methods, convertJSONToClassA, convertJSONToClassB, convertJSONToClassC and so on?</p>