How to re-use code when use gson to parse json file?
<p>I got a problem when I use gson to parse json file. I want to deserialize some similar json files
to my objects. I typed a method to do this job, but I don't know how to apply this method to different json files. These json files have some similar structures, so I want to deserialize them into subtypes of the same supertypes.</p>

<pre><code>    private Map&lt;String, PatternDetectionRequestBody&gt; readRequestFromJson(File jsonFile) {
        Map&lt;String, PatternDetectionRequestBody&gt; requestBodyMap = null;
        try {
            FileReader fileReader = new FileReader(jsonFile);
            JsonReader jsonReader = new JsonReader(fileReader);
            Gson gson = new Gson();
            Type type = new TypeToken&lt;Map&lt;String, PatternDetectionRequestBody&gt;&gt;(){}.getType();
            requestBodyMap = gson.fromJson(jsonReader, type);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        return requestBodyMap;
}
</code></pre>

<p>As code above, I want to use this code to parse different json files by changing <strong>PatternDetectionRequestBody</strong> to some sibling classes. Could anyone tell me how to do this?</p>