+ Start a Discussion
CloudGeekCloudGeek 

Wrapper returning array of arrays: how to convert it into a single dimensional JSON Object

Hi,

I have a wrapper returning an array of arrays (list):

The code for apex method is as follows:
 
public static List<OnlineSalesCatalogWrapperUI> getOnlineSalesCatalogWrapperUIForRegion( String region ) {
        System.debug( 'getOnlineSalesCatalogWrapperUIForRegion(' + region + ')...' );
        Map<String,OnlineSalesCatalogWrapperUI> wrapperUIMap = new Map<String,OnlineSalesCatalogWrapperUI>();
        List<OnlineSalesCatalogWrapper> catalogItems = getOnlineSalesCatalogListForRegion( region );
        List<OnlineSalesCatalogWrapperUI> catalogWrapperUIs = new List<OnlineSalesCatalogWrapperUI>();
        OnlineSalesCatalogWrapperUI catalogWrapperUI = null;
        for ( OnlineSalesCatalogWrapper catalogItem : catalogItems ) {
            // Enable each item for initial load
            catalogItem.visible = true;
            // Each onlineSalesCatalogWrapper object has a different title based on the segment and 
            // OfferTypeDescription.
            String catalogUIKey = catalogItem.segment + ':' + catalogItem.offerType;
            if ( wrapperUIMap.containsKey(catalogUIKey)) { 
                // fetch the existing wrapper UI object to store this catalog wrapper
                catalogWrapperUI = wrapperUIMap.get( catalogUIKey );
                catalogWrapperUI.add( catalogItem );
            } else {
                // create a new wrapper UI object
                catalogWrapperUI = new OnlineSalesCatalogWrapperUI( catalogItem );
                wrapperUIMap.put( catalogUIKey, catalogWrapperUI );
                catalogWrapperUIs.add( catalogWrapperUI );
            }
            /** OBSOLETE BLOCK
            if ( catalogWrapperUI == null ) {
                // first time through the loop -- create a new CatalogWrapperUI object
                catalogWrapperUI = new OnlineSalesCatalogWrapperUI( catalogItem );
                catalogWrapperUIs.add( catalogWrapperUI );
            } else if ( catalogWrapperUI.matches( catalogItem )) {
                // add to the wrapper UI under that segment/offerTypeDescription...
                catalogWrapperUI.add( catalogItem );
            } else {
                // Did not match.  Create a new segment/offerType for this UI.
                catalogWrapperUI = new OnlineSalesCatalogWrapperUI( catalogItem );
                catalogWrapperUIs.add( catalogWrapperUI );
            }
                        ***/
        }
        return catalogWrapperUIs;
    }


and the received response when we called this method as REST service is shown sample below:
 
[{"wrappers":

[{"wrapperId":"offera2y19000000LYsRAAW_01ui000000MSJPHAA5_01u1900000BNsEVAA1","visible":true,"trialUnit":"Day","trialDuration":30,"trialDescription":"30 days","shortQBOProductName":"Essentials","shortPayrollProductName":"Full Service Payroll","segment":"New to QBO","region":"USA","qboProductPriceBookId":null,"qboProductPriceBookEntryId":"01ui000000MSJPHAA5","productCreateStr":"01ui000000MSJPHAA5|01u1900000BNsEVAA1|null|nullAmount|null|null","productCode":"QBP-T3P","payrollProductPriceBookId":null,"payrollProductPriceBookEntryId":"01u1900000BNsEVAA1","payrollListPrice":99.00,"payrollDiscountUnit":"MONTH","payrollDiscountType":"PERCENT","payrollDiscountedPrice":null,"payrollDiscountDuration":12,"payrollDiscountDescription":"20% discount for 1 year","payrollDiscountAmount":20.00,"payrollAnnualListPrice":null,"payrollAnnualDiscountedPrice":null,"offerTypeDescription":"Trial","offerType":"TRIAL","offerId":"a2y19000000LYsRAAW","offeredQBOProductId":null,"offeredQBOProduct":"QuickBooks Online Essentials","offeredPayrollProductId":null,"offeredPayrollProduct":"QuickBooks Online Payroll Full Service","listPrice":26.95,"listCurrencyCode":null,"isTrial":true,"hasDiscountAsString":"false","hasDiscount":false,"displayProductName":"QuickBooks Online Essentials w/Full Service Payroll","discountUnit":null,"discountType":null,"discountedPrice":null,"discountDuration":null,"discountDescription":null,"discountAmount":null,"currencyCode":"USD","bundleListPrice":125.95,"bundleDiscountedPrice":null,"bundleDiscountAmount":null,"annualListPrice":289.95,"annualDiscountedPrice":null},{"wrapperId":"offera2y19000000LYsRAAW_01ui000000MSJPHAA5_01u1900000BNsEUAA1","visible":true,"trialUnit":"Day","trialDuration":30,"trialDescription":"30 days","shortQBOProductName":"Essentials","shortPayrollProductName":"Enhanced Payroll","segment":"New to QBO","region":"USA","qboProductPriceBookId":null,"qboProductPriceBookEntryId":"01ui000000MSJPHAA5","productCreateStr":"01ui000000MSJPHAA5|01u1900000BNsEUAA1|null|nullAmount|null|null","productCode":"QBP-T3P","payrollProductPriceBookId":null,"payrollProductPriceBookEntryId":"01u1900000BNsEUAA1","payrollListPrice":39.00,"payrollDiscountUnit":"MONTH","payrollDiscountType":"PERCENT","payrollDiscountedPrice":null,"payrollDiscountDuration":12,"payrollDiscountDescription":"20% discount for 1 year","payrollDiscountAmount":20.00,"payrollAnnualListPrice":null,"payrollAnnualDiscountedPrice":null,"offerTypeDescription":"Trial","offerType":"TRIAL","offerId":"a2y19000000LYsRAAW","offeredQBOProductId":null,"offeredQBOProduct":"QuickBooks Online Essentials","offeredPayrollProductId":null,"offeredPayrollProduct":"QuickBooks Online Payroll Enhanced","listPrice":26.95,"listCurrencyCode":null,"isTrial":true,"hasDiscountAsString":"false","hasDiscount":false,"displayProductName":"QuickBooks Online Essentials w/Enhanced Payroll","discountUnit":null,"discountType":null,"discountedPrice":null,"discountDuration":null,"discountDescription":null,"discountAmount":null,"currencyCode":"USD","bundleListPrice":65.95,"bundleDiscountedPrice":null,"bundleDiscountAmount":null,"annualListPrice":289.95,"annualDiscountedPrice":null},{"wrapperId":"offera2y19000000LZ53AAG_01ui000000MSJPHAA5_01u1900000BNsEVAA1","visible":true,"trialUnit":"Day","trialDuration":30,"trialDescription":"30 days","shortQBOProductName":"Essentials","shortPayrollProductName":"Full Service Payroll","segment":"New to QBO","region":"USA","qboProductPriceBookId":null,"qboProductPriceBookEntryId":"01ui000000MSJPHAA5","productCreateStr":"01ui000000MSJPHAA5|01u1900000BNsEVAA1|null|nullAmount|21.560000|null","productCode":"USE-T6P","payrollProductPriceBookId":null,"payrollProductPriceBookEntryId":"01u1900000BNsEVAA1","payrollListPrice":99.00,"payrollDiscountUnit":"MONTH","payrollDiscountType":"PERCENT","payrollDiscountedPrice":null,"payrollDiscountDuration":12,"payrollDiscountDescription":"20% discount for 1 year","payrollDiscountAmount":20.00,"payrollAnnualListPrice":null,"payrollAnnualDiscountedPrice":null,"offerTypeDescription":"Trial","offerType":"TRIAL","offerId":"a2y19000000LZ53AAG","offeredQBOProductId":null,"offeredQBOProduct":"QuickBooks Online Essentials","offeredPayrollProductId":null,"offeredPayrollProduct":"QuickBooks Online Payroll Full Service","listPrice":26.95,"listCurrencyCode":null,"isTrial":true,"hasDiscountAsString":"true","hasDiscount":true,"displayProductName":"QuickBooks Online Essentials w/Full Service Payroll","discountUnit":"DAY","discountType":"PERCENT","discountedPrice":21.560000,"discountDuration":365,"discountDescription":"20% discount for 1 year","discountAmount":20.00,"currencyCode":"USD","bundleListPrice":125.95,"bundleDiscountedPrice":100.760000,"bundleDiscountAmount":20.00,"annualListPrice":289.95,"annualDiscountedPrice":null},{"wrapperId":"offera2y19000000LZ53AAG_01ui000000MSJPHAA5_01u1900000BNsEUAA1","visible":true,"trialUnit":"Day","trialDuration":30,"trialDescription":"30 days","shortQBOProductName":"Essentials","shortPayrollProductName":"Enhanced Payroll","segment":"New to QBO","region":"USA","qboProductPriceBookId":null,"qboProductPriceBookEntryId":"01ui000000MSJPHAA5","productCreateStr":"01ui000000MSJPHAA5|01u1900000BNsEUAA1|null|nullAmount|21.560000|null","productCode":"USE-T6P","payrollProductPriceBookId":null,"payrollProductPriceBookEntryId":"01u1900000BNsEUAA1","payrollListPrice":39.00,"payrollDiscountUnit":"MONTH","payrollDiscountType":"PERCENT","payrollDiscountedPrice":null,"payrollDiscountDuration":12,"payrollDiscountDescription":"20% discount for 1 year","payrollDiscountAmount":20.00,"payrollAnnualListPrice":null,"payrollAnnualDiscountedPrice":null,"offerTypeDescription":"Trial","offerType":"TRIAL","offerId":"a2y19000000LZ53AAG","offeredQBOProductId":null,"offeredQBOProduct":"QuickBooks Online Essentials","offeredPayrollProductId":null,"offeredPayrollProduct":"QuickBooks Online Payroll Enhanced","listPrice":26.95,"listCurrencyCode":null,"isTrial":true,"hasDiscountAsString":"true","hasDiscount":true,"displayProductName":"QuickBooks Online Essentials w/Enhanced Payroll","discountUnit":"DAY","discountType":"PERCENT","discountedPrice":21.560000,"discountDuration":365,"discountDescription":"20% discount for 1 year","discountAmount":20.00,"currencyCode":"USD","bundleListPrice":65.95,"bundleDiscountedPrice":52.760000,"bundleDiscountAmount":20.00,"annualListPrice":289.95,"annualDiscountedPrice":null},{"wrapperId":"offera2y19000000LZ56AAG_01ui000000MSJOqAAP_01u1900000BNsEUAA1","visible":true,"trialUnit":"Day","trialDuration":30,"trialDescription":"30 days","shortQBOProductName":"Simple Start","shortPayrollProductName":"Enhanced Payroll","segment":"New to QBO","region":"USA","qboProductPriceBookId":null,"qboProductPriceBookEntryId":"01ui000000MSJOqAAP","productCreateStr":"01ui000000MSJOqAAP|01u1900000BNsEUAA1|null|nullAmount|10.360000|null","productCode":"USS-T2P","payrollProductPriceBookId":null,"payrollProductPriceBookEntryId":"01u1900000BNsEUAA1","payrollListPrice":39.00,"payrollDiscountUnit":"MONTH","payrollDiscountType":"PERCENT","payrollDiscountedPrice":null,"payrollDiscountDuration":12,"payrollDiscountDescription":"20% discount for 1 year","payrollDiscountAmount":20.00,"payrollAnnualListPrice":null,"payrollAnnualDiscountedPrice":null,"offerTypeDescription":"Trial","offerType":"TRIAL","offerId":"a2y19000000LZ56AAG","offeredQBOProductId":null,"offeredQBOProduct":"QuickBooks Online Simple Start","offeredPayrollProductId":null,"offeredPayrollProduct":"QuickBooks Online Payroll Enhanced","listPrice":12.95,"listCurrencyCode":null,"isTrial":true,"hasDiscountAsString":"true","hasDiscount":true,"displayProductName":"QuickBooks Online Simple Start w/Enhanced Payroll","discountUnit":"DAY","discountType":"PERCENT","discountedPrice":10.360000,"discountDuration":365,"discountDescription":"20% discount for 1 year","discountAmount":20.00,"currencyCode":"USD","bundleListPrice":51.95,"bundleDiscountedPrice":41.560000,"bundleDiscountAmount":20.00,"annualListPrice":137.95,"annualDiscountedPrice":null},{"wrapperId":"offera2y19000000LZ56AAG_01ui000000MSJOqAAP_01u1900000BNsEVAA1","visible":true,"trialUnit":"Day","trialDuration":30,"trialDescription":"30 days","shortQBOProductName":"Simple Start","shortPayrollProductName":"Full Service Payroll","segment":"New to QBO","region":"USA","qboProductPriceBookId":null,"qboProductPriceBookEntryId":"01ui000000MSJOqAAP","productCreateStr":"01ui000000MSJOqAAP|01u1900000BNsEVAA1|null|nullAmount|10.360000|null","productCode":"USS-T2P","payrollProductPriceBookId":null,"payrollProductPriceBookEntryId":"01u1900000BNsEVAA1","payrollListPrice":99.00,"payrollDiscountUnit":"MONTH","payrollDiscountType":"PERCENT","payrollDiscountedPrice":null,"payrollDiscountDuration":12,"payrollDiscountDescription":"20% discount for 1 year","payrollDiscountAmount":20.00,"payrollAnnualListPrice":null,"payrollAnnualDiscountedPrice":null,"offerTypeDescription":"Trial","offerType":"TRIAL","offerId":"a2y19000000LZ56AAG","offeredQBOProductId":null,"offeredQBOProduct":"QuickBooks Online Simple Start","offeredPayrollProductId":null,"offeredPayrollProduct":"QuickBooks Online Payroll Full Service","listPrice":12.95,"listCurrencyCode":null,"isTrial":true,"hasDiscountAsString":"true","hasDiscount":true,"displayProductName":"QuickBooks Online Simple Start w/Full Service Payroll","discountUnit":"DAY","discountType":"PERCENT","discountedPrice":10.360000,"discountDuration":365,"discountDescription":"20% discount for 1 year","discountAmount":20.00,"currencyCode":"USD","bundleListPrice":111.95,"bundleDiscountedPrice":89.560000,"bundleDiscountAmount":20.00,"annualListPrice":137.95,"annualDiscountedPrice":null},{"wrapperId":"offera2y19000000LYsdAAG_01ui000000MSJOqAAP_01u1900000BNsEUAA1","visible":true,"trialUnit":"Day","trialDuration":30,"trialDescription":"30 days","shortQBOProductName":"Simple Start","shortPayrollProductName":"Enhanced Payroll","segment":"New to QBO","region":"USA","qboProductPriceBookId":null,"qboProductPriceBookEntryId":"01ui000000MSJOqAAP","productCreateStr":"01ui000000MSJOqAAP|01u1900000BNsEUAA1|null|nullAmount|null|null","productCode":"USS-THP","payrollProductPriceBookId":null,"payrollProductPriceBookEntryId":"01u1900000BNsEUAA1","payrollListPrice":39.00,"payrollDiscountUnit":null,"payrollDiscountType":null,"payrollDiscountedPrice":null,"payrollDiscountDuration":null,"payrollDiscountDescription":null,"payrollDiscountAmount":null,"payrollAnnualListPrice":null,"payrollAnnualDiscountedPrice":null,"offerTypeDescription":"Trial","offerType":"TRIAL","offerId":"a2y19000000LYsdAAG","offeredQBOProductId":null,"offeredQBOProduct":"QuickBooks Online Simple Start","offeredPayrollProductId":null,"offeredPayrollProduct":"QuickBooks Online Payroll Enhanced","listPrice":12.95,"listCurrencyCode":null,"isTrial":true,"hasDiscountAsString":"false","hasDiscount":false,"displayProductName":"QuickBooks Online Simple Start w/Enhanced Payroll","discountUnit":null,"discountType":null,"discountedPrice":null,"discountDuration":null,"discountDescription":null,"discountAmount":null,"currencyCode":"USD","bundleListPrice":51.95,"bundleDiscountedPrice":null,"bundleDiscountAmount":null,"annualListPrice":120.00,"annualDiscountedPrice":null},{"wrapperId":"offera2y19000000LYsdAAG_01ui000000MSJOqAAP_01u1900000BNsEVAA1","visible":true,"trialUnit":"Day","trialDuration":30,"trialDescription":"30 days","shortQBOProductName":"Simple Start","shortPayrollProductName":"Full Service Payroll","segment":"New to QBO","region":"USA","qboProductPriceBookId":null,"qboProductPriceBookEntryId":"01ui000000MSJOqAAP","productCreateStr":"01ui000000MSJOqAAP|01u1900000BNsEVAA1|null|nullAmount|null|null","productCode":"USS-THP","payrollProductPriceBookId":null,"payrollProductPriceBookEntryId":"01u1900000BNsEVAA1","payrollListPrice":99.00,"payrollDiscountUnit":null,"payrollDiscountType":null,"payrollDiscountedPrice":null,"payrollDiscountDuration":null,"payrollDiscountDescription":null,"payrollDiscountAmount":null,"payrollAnnualListPrice":null,"payrollAnnualDiscountedPrice":null,"offerTypeDescription":"Trial","offerType":"TRIAL","offerId":"a2y19000000LYsdAAG","offeredQBOProductId":null,"offeredQBOProduct":"QuickBooks Online Simple Start","offeredPayrollProductId":null,"offeredPayrollProduct":"QuickBooks Online Payroll Full Service","listPrice":12.95,"listCurrencyCode":null,"isTrial":true,"hasDiscountAsString":"false","hasDiscount":false,"displayProductName":"QuickBooks Online Simple Start w/Full Service Payroll","discountUnit":null,"discountType":null,"discountedPrice":null,"discountDuration":null,"discountDescription":null,"discountAmount":null,"currencyCode":"USD","bundleListPrice":111.95,"bundleDiscountedPrice":null,"bundleDiscountAmount":null,"annualListPrice":120.00,"annualDiscountedPrice":null}],"visible":true,"title":"New to QBO - Trial","segment":"New to QBO","offerTypeDescription":"Trial","offerType":"TRIAL","isTrial":true,"countOfWrappers":8
},


{"wrappers":
[{"wrapperId":"offera2y19000000LYrnAAG_01ui000000MSJPHAA5_null","visible":true,"trialUnit":"Day","trialDuration":0,"trialDescription":"0 day","shortQBOProductName":"Essentials","shortPayrollProductName":null,"segment":"New to QBO","region":"USA","qboProductPriceBookId":null,"qboProductPriceBookEntryId":"01ui000000MSJPHAA5","productCreateStr":null,"productCode":"USE-B90","payrollProductPriceBookId":null,"payrollProductPriceBookEntryId":null,"payrollListPrice":null,"payrollDiscountUnit":null,"payrollDiscountType":null,"payrollDiscountedPrice":null,"payrollDiscountDuration":null,"payrollDiscountDescription":null,"payrollDiscountAmount":null,"payrollAnnualListPrice":null,"payrollAnnualDiscountedPrice":null,"offerTypeDescription":"Buy Now","offerType":"PAID","offerId":"a2y19000000LYrnAAG","offeredQBOProductId":null,"offeredQBOProduct":"QuickBooks Online Essentials","offeredPayrollProductId":null,"offeredPayrollProduct":null,"listPrice":26.95,"listCurrencyCode":null,"isTrial":false,"hasDiscountAsString":"true","hasDiscount":true,"displayProductName":"QuickBooks Online Essentials","discountUnit":"DAY","discountType":"PERCENT","discountedPrice":16.170000,"discountDuration":365,"discountDescription":"40% discount for 1 year","discountAmount":40.00,"currencyCode":"USD","bundleListPrice":26.95,"bundleDiscountedPrice":16.170000,"bundleDiscountAmount":40.00,"annualListPrice":199.90,"annualDiscountedPrice":null},{"wrapperId":"offera2y19000000LYsYAAW_01ui000000MSJOqAAP_01u1900000BNsEVAA1","visible":true,"trialUnit":"Day","trialDuration":0,"trialDescription":"0 day","shortQBOProductName":"Simple Start","shortPayrollProductName":"Full Service Payroll","segment":"New to QBO","region":"USA","qboProductPriceBookId":null,"qboProductPriceBookEntryId":"01ui000000MSJOqAAP","productCreateStr":"01ui000000MSJOqAAP|01u1900000BNsEVAA1|null|nullAmount|6.475000|null","productCode":"USS-B2P","payrollProductPriceBookId":null,"payrollProductPriceBookEntryId":"01u1900000BNsEVAA1","payrollListPrice":99.00,"payrollDiscountUnit":"MONTH","payrollDiscountType":"PERCENT","payrollDiscountedPrice":null,"payrollDiscountDuration":6,"payrollDiscountDescription":"50% discount for 6 months","payrollDiscountAmount":50.00,"payrollAnnualListPrice":null,"payrollAnnualDiscountedPrice":null,"offerTypeDescription":"Buy Now","offerType":"PAID","offerId":"a2y19000000LYsYAAW","offeredQBOProductId":null,"offeredQBOProduct":"QuickBooks Online Simple Start","offeredPayrollProductId":null,"offeredPayrollProduct":"QuickBooks Online Payroll Full Service","listPrice":12.95,"listCurrencyCode":null,"isTrial":false,"hasDiscountAsString":"true","hasDiscount":true,"displayProductName":"QuickBooks Online Simple Start w/Full Service Payroll","discountUnit":"MONTH","discountType":"PERCENT","discountedPrice":6.475000,"discountDuration":6,"discountDescription":"50% discount for 6 months","discountAmount":50.00,"currencyCode":"USD","bundleListPrice":111.95,"bundleDiscountedPrice":55.975000,"bundleDiscountAmount":50.00,"annualListPrice":137.95,"annualDiscountedPrice":null},{"wrapperId":"offera2y19000000LYsYAAW_01ui000000MSJOqAAP_01u1900000BNsEUAA1","visible":true,"trialUnit":"Day","trialDuration":0,"trialDescription":"0 day","shortQBOProductName":"Simple Start","shortPayrollProductName":"Enhanced Payroll","segment":"New to QBO","region":"USA","qboProductPriceBookId":null,"qboProductPriceBookEntryId":"01ui000000MSJOqAAP","productCreateStr":"01ui000000MSJOqAAP|01u1900000BNsEUAA1|null|nullAmount|6.475000|null","productCode":"USS-B2P","payrollProductPriceBookId":null,"payrollProductPriceBookEntryId":"01u1900000BNsEUAA1","payrollListPrice":39.00,"payrollDiscountUnit":"MONTH","payrollDiscountType":"PERCENT","payrollDiscountedPrice":null,"payrollDiscountDuration":6,"payrollDiscountDescription":"50% discount for 6 months","payrollDiscountAmount":50.00,"payrollAnnualListPrice":null,"payrollAnnualDiscountedPrice":null,"offerTypeDescription":"Buy Now","offerType":"PAID","offerId":"a2y19000000LYsYAAW","offeredQBOProductId":null,"offeredQBOProduct":"QuickBooks Online Simple Start","offeredPayrollProductId":null,"offeredPayrollProduct":"QuickBooks Online Payroll Enhanced","listPrice":12.95,"listCurrencyCode":null,"isTrial":false,"hasDiscountAsString":"true","hasDiscount":true,"displayProductName":"QuickBooks Online Simple Start w/Enhanced Payroll","discountUnit":"MONTH","discountType":"PERCENT","discountedPrice":6.475000,"discountDuration":6,"discountDescription":"50% discount for 6 months","discountAmount":50.00,"currencyCode":"USD","bundleListPrice":51.95,"bundleDiscountedPrice":25.975000,"bundleDiscountAmount":50.00,"annualListPrice":137.95,"annualDiscountedPrice":null}],"visible":true,"title":"New to QBO - Buy Now","segment":"New to QBO","offerTypeDescription":"Buy Now","offerType":"PAID","isTrial":false,"countOfWrappers":3},


 
Best Answer chosen by CloudGeek
pconpcon
I would do this by making a WrapperWrapper class, deserializing your body into that, and then adding the internal wrappers to a list.
 
public class Wrapper {
	String wrapperId;
    Boolean visible;
}

public class WrapperWrapper {
    List<Wrapper> wrappers;
    Boolean visible;
    Integer countOfWrappers;
    String title;
}

Http h = new Http();
HttpRequest req = new HttpRequest();
req.setMethod('GET');
req.setEndpoint('http://paste.deadlypenguin.com/psl0yrek3/tjpau8/raw');
HttpResponse res = h.send(req);



List<Wrapper> wrappers = new List<Wrapper>();
for (WrapperWrapper ww : (List<WrapperWrapper>)(JSON.deserialize(res.getBody(), List<WrapperWrapper>.class))) {
    wrappers.addAll(ww.wrappers);
}
     
System.debug(System.LoggingLevel.ERROR, wrappers.size());

The paste url just has the JSON you provided.  I abbreviated the contents of the Wrapper object, so you would want to include all the fields you care about.

All Answers

pconpcon
I would do this by making a WrapperWrapper class, deserializing your body into that, and then adding the internal wrappers to a list.
 
public class Wrapper {
	String wrapperId;
    Boolean visible;
}

public class WrapperWrapper {
    List<Wrapper> wrappers;
    Boolean visible;
    Integer countOfWrappers;
    String title;
}

Http h = new Http();
HttpRequest req = new HttpRequest();
req.setMethod('GET');
req.setEndpoint('http://paste.deadlypenguin.com/psl0yrek3/tjpau8/raw');
HttpResponse res = h.send(req);



List<Wrapper> wrappers = new List<Wrapper>();
for (WrapperWrapper ww : (List<WrapperWrapper>)(JSON.deserialize(res.getBody(), List<WrapperWrapper>.class))) {
    wrappers.addAll(ww.wrappers);
}
     
System.debug(System.LoggingLevel.ERROR, wrappers.size());

The paste url just has the JSON you provided.  I abbreviated the contents of the Wrapper object, so you would want to include all the fields you care about.
This was selected as the best answer
CloudGeekCloudGeek
Hey Pcon,

This is what exactly I need. Works a treat!
Thank you so much!