Code example for Gson

Methods: fromJson

0
        } 
    } 
 
    private Map<String, Object> getModelMap(String testName) {
        String json = readFile(testName + ".json");
        Gson gson = new Gson();
        Type type = new TypeToken<Map<String, Object>>() {
        }.getType();
        Map<String, Object> model = gson.fromJson(json, type);
        if (model == null) {
            model = new HashMap<String, Object>();
        } 
        return model;
    } 
 
    private String readFile(String fileName) {
        try { 
            return FileUtils.readFileToString(new File(TestFileHelper.getCompilerErrorsResourcePath(fileName)));
        } catch (Exception e) {
            // e.printStackTrace(); 
Experience pair programming with AI  Get Codota for Java