Code example for Gson

Methods: fromJson

0
        return feedback;
    } 
 
    private List<Feedback> cursorToFeedback(Cursor cursor) {
        String json = cursor.getString(0);
        Gson gson = new Gson();
        try { 
            Type listType = new TypeToken<List<Feedback>>(){}.getType();
            List<Feedback> feedback = gson.fromJson(json, listType);
            return feedback;
        } 
 
        catch (Exception e) {
            throw new PersistenceException("Could not load host feedback"); 
        } 
    } 
 
    public List<HostBriefInfo> getAllBrief() {
        Cursor cursor = database.query(DbHelper.TABLE_HOSTS, new String[] { DbHelper.COLUMN_ID,
                DbHelper.COLUMN_DETAILS, DbHelper.COLUMN_UPDATED }, null, null, null, null, null); 
Experience pair programming with AI  Get Codota for Java