Code example for Gson

0
        LOGI(TAG, "Received GCM message: " + type);
        int syncJitter;
        SyncData syncData = null;
        if (extraData != null) {
            try { 
                Gson gson = new Gson();
                syncData = gson.fromJson(extraData, SyncData.class);
            } catch (JsonSyntaxException e) {
                LOGI(TAG, "Error while decoding extraData: " + e.toString());
            } 
        } 
 
        // TODO(trevorjohns): Make this so there's a configurable sync and jitter. 
        // TODO(trevorjohns): Also, use superclass to reduce duplcated code between this and SyncCommand 
        if (syncData != null && syncData.sync_jitter != 0) {
            syncJitter = syncData.sync_jitter;
        } else { 
            syncJitter = DEFAULT_TRIGGER_SYNC_DELAY;
        }