I’m using a new API but am getting back responses like this.
{"status":"ok","status_message":"","total_resource_count":"2602","products":["{\"product_id\":\"26\",\"title\":\"MAXLINER
Custom Fit Floor Mats 2 Rows and Cargo Liner Set Black for 2007-2011 Honda
CR-V\",\"mfg\":\"\",\"qb_product_id\":null,\"condition\":\"\",\"cat\":\"\",\"sub_cat\":\"\",\"src\":null,\"ship_weight\":\"416\",\"default_location\":\"4898\",\"pref_ship_meth\":\"106\",\"style\":\"A0021\\\/B0021\\\/D0014\",\"style1\":null,\"vendor_style\":null,\"Parent_SKU\":\"\",\"upc\":\"609788050940\",\"desc\":\"Coverage
for First, Second Row Seats and Cargo Area Only\",\"notes\":\"Fits All
Models\",\"status\":\"1\",\"location\":null,\"warehouse\":\"\",\"listedamz\":null,\"listed_amazon1\":\"0\",\"amazon1_sku\":\"\",\"amazon1_asin\":\"\",\"amazon1_listing_id\":null,\"amazon1_price\":\"0\",\"amazon1_buffer\":\"0\",\"listed_amazon2\":\"0\",\"amazon2_sku\":null,\"amazon2_asin\":null,\"amazon2_listing_id\":null,\"amazon2_price\":\"0\",\"listed_walmart\":\"0\",\"walmart_sku\":\"\",\"walmart_listing_id\":\"\",\"walmart_buffer\":\"0\",\"walmart_price\":\"0\",\"amazon2_buffer\":\"0\",\"listed_ebay\":\"0\",\"ebay_sku\":\"\",\"ebay_listing_id\":\"\",\"ebay_price\":\"0\",\"ebay_buffer\":\"0\",\"ebay_category_id\":\"0\",\"listed_wish\":\"0\",\"wish_sku\":null,\"wish_listing_id\":null,\"wish_price\":\"0\",\"wish_buffer\":\"0\",\"listed_shopify1\":\"0\",\"shopify1_sku\":\"\",\"shopify1_listing_id\":\"\",\"shopify1_variant_id\":null,\"shopify1_inventory_item_id\":null,\"shopify1_location\":null,\"shopify1_price\":\"0\",\"shopify1_buffer\":\"0\",\"Bullet_Point_1\":\"\",\"Bullet_Point_2\":\"ALL
WEATHER PROTECTION - All-weather, stain-resistant protection that gives your car, van, truck, or SUV interior a first
class look while protecting its resale value.\",\"Bullet_Point_3\":\"CUSTOM FIT - The raised lip and custom design
constructed using innovative vehicle scanning technology ensures the perfect fit that protects your vehicle?s carpet
floor from the weather, spills and any messes.\",\"Bullet_Point_4\":\"EASY TO INSTALL & CLEAN - Textured, skid resistant
surface made from 100% recyclable materials offers 100% odorless protection that is easy to clean by hosing off or using
soap and water.\",\"Bullet_Point_5\":\"LIFETIME WARRANTY - Strong, durable, easy to install, and backed by a limited
Lifetime
Warranty.\",\"Image1_URL\":\"https:\\\/\\\/www.maxtray.com\\\/media\\\/webimages\\\/A0021_B0021_D0014\\\/AMZ\\\/A0021_B0021_D0014.jpg\",\"Image2_URL\":\"\",\"Image3_URL\":\"\",\"Image4_URL\":\"\",\"Image5_URL\":\"\",\"qty\":\"0\",\"casepack\":\"1\",\"cost\":\"0\",\"landed_cost\":\"0\",\"price\":\"0\",\"prd_kit\":\"2\",\"kit_ship_settings\":\"1\",\"alertqty\":null,\"discontinued\":\"0\",\"one_per_box\":\"0\",\"box_size\":\"\",\"uom\":\"\",\"tags\":\"[\\\"\\\"]\",\"company\":\"0\",\"dim1\":\"48\",\"dim2\":\"32\",\"dim3\":\"6\",\"case_dim1\":\"0\",\"case_dim2\":\"0\",\"case_dim3\":\"0\",\"listed_sears\":\"0\",\"last_rec_in_main\":null,\"last_sent_fba\":null,\"wh_sell_price\":\"0\",\"retail_sell_price\":\"0\",\"prj_days\":\"7\",\"lead_time\":\"7\",\"oversized\":\"0\",\"case_weight\":\"\",\"case_upc\":\"\",\"prod_qty_per_pallet\":\"0\",\"invt_type\":\"0\",\"prod_type\":\"0\",\"date_created\":\"2022-01-14
14:45:55\",\"aafes_buffer\":\"0\",\"aafes_listing_id\":null,\"aafes_price\":\"0\",\"aafes_sku\":null,\"amazon3_buffer\":\"0\",\"amazon3_listing_id\":null,\"amazon3_price\":\"0\",\"amazon3_sku\":null,\"amazon4_buffer\":\"0\",\"amazon4_listing_id\":null,\"amazon4_price\":\"0\",\"amazon4_sku\":null,\"amazondfca_asin\":null,\"amazondfca_buffer\":\"0\",\"amazondfca_listing_id\":null,\"amazondfca_price\":\"0\",\"amazondfca_sku\":null,\"amazondf_asin\":null,\"amazondf_buffer\":\"0\",\"amazondf_listing_id\":\"\",\"amazondf_price\":\"0\",\"amazondf_sku\":\"\",\"bbb_buffer\":\"0\",\"bbb_listing_id\":null,\"bbb_price\":\"0\",\"bbb_sku\":null,\"belk_buffer\":\"0\",\"belk_listing_id\":null,\"belk_price\":\"0\",\"belk_sku\":null,\"bestbuy_buffer\":\"0\",\"bestbuy_listing_id\":null,\"bestbuy_price\":\"0\",\"bestbuy_sku\":null,\"bjs_buffer\":\"0\",\"bjs_listing_id\":null,\"bjs_price\":\"0\",\"bjs_sku\":null,\"color\":null,\"dailysteals_listing_id\":null,\"dailysteals_price\":\"0\",\"dailysteals_sku\":null,\"domestify_buffer\":\"0\",\"domestify_listing_id\":null,\"domestify_price\":\"0\",\"domestify_sku\":null,\"groupon_buffer\":\"0\",\"groupon_listing_id\":null,\"groupon_price\":\"0\",\"groupon_sku\":null,\"home_depot_buffer\":\"0\",\"home_depot_listing_id\":null,\"home_depot_price\":\"0\",\"home_depot_sku\":null,\"hsn_buffer\":\"0\",\"hsn_listing_id\":null,\"hsn_price\":\"0\",\"hsn_sku\":null,\"jcpenney_buffer\":\"0\",\"jcpenney_listing_id\":null,\"jcpenney_price\":\"0\",\"jcpenney_sku\":null,\"kroger_buffer\":\"0\",\"kroger_listing_id\":null,\"kroger_price\":\"0\",\"kroger_sku\":null,\"listed_aafes\":\"0\",\"listed_amazon3\":\"0\",\"listed_amazon4\":\"0\",\"listed_amazondf\":\"0\",\"listed_amazondfca\":\"0\",\"listed_bbb\":\"0\",\"listed_belk\":\"0\",\"listed_bestbuy\":\"0\",\"listed_bjs\":\"0\",\"listed_dailysteals\":\"0\",\"listed_domestify\":\"0\",\"listed_groupon\":\"0\",\"listed_home_depot\":\"0\",\"listed_hsn\":\"0\",\"listed_jcpenney\":\"0\",\"listed_kroger\":\"0\",\"listed_lowes\":\"0\",\"listed_lowesca\":\"0\",\"listed_macys\":\"0\",\"listed_magento\":\"0\",\"listed_nordstrom\":\"0\",\"listed_qvc\":\"0\",\"listed_samsclub\":\"0\",\"listed_target\":\"0\",\"listed_tractorsupply\":\"0\",\"listed_walmartdsv\":\"0\",\"listed_zulily\":\"0\",\"lowesca_buffer\":\"0\",\"lowesca_listing_id\":null,\"lowesca_price\":\"0\",\"lowesca_sku\":null,\"lowes_buffer\":\"0\",\"lowes_listing_id\":null,\"lowes_price\":\"0\",\"lowes_sku\":null,\"macys_buffer\":\"0\",\"macys_listing_id\":null,\"macys_price\":\"0\",\"macys_sku\":null,\"magento_buffer\":\"0\",\"magento_listing_id\":null,\"magento_price\":\"0\",\"magento_sku\":null,\"nordstrom_buffer\":\"0\",\"nordstrom_listing_id\":null,\"nordstrom_price\":\"0\",\"nordstrom_sku\":null,\"qvc_buffer\":\"0\",\"qvc_listing_id\":null,\"qvc_price\":\"0\",\"qvc_sku\":null,\"samsclub_buffer\":\"0\",\"samsclub_listing_id\":null,\"samsclub_price\":\"0\",\"samsclub_sku\":null,\"sears_listing_id\":null,\"sears_price\":\"0\",\"sears_sku\":null,\"size\":null,\"target_buffer\":\"0\",\"target_listing_id\":null,\"target_price\":\"0\",\"target_sku\":null,\"tractorsupply_buffer\":\"0\",\"tractorsupply_listing_id\":null,\"tractorsupply_price\":\"0\",\"tractorsupply_sku\":null,\"walmartdsv_buffer\":\"0\",\"walmartdsv_listing_id\":null,\"walmartdsv_price\":\"0\",\"walmartdsv_sku\":null,\"zulily_buffer\":\"0\",\"zulily_listing_id\":null,\"zulily_price\":\"0\",\"zulily_sku\":null,\"zulily_upc\":null}"]}
It looks like all of the objects inside of the arrays are in strings, how would I go about removing them from these strings in python so that I can access the objects key-value pairs?
>Solution :
You need to parse the Product strings as JSON.
something like this:
import json
payload = {"status":"ok","status_message":"","total_resource_count":"2602","products":["{\"product_id\":\"26\",\"title\":\"MAXLINER Custom Fit Floor Mats 2 Rows and Cargo Liner Set Black for 2007-2011 HondaCR-V\",\"mfg\":\"\",\"qb_product_id\":null,\"condition\":\"\",\"cat\":\"\",\"sub_cat\":\"\",\"src\":null,\"ship_weight\":\"416\",\"default_location\":\"4898\",\"pref_ship_meth\":\"106\",\"style\":\"A0021\\\/B0021\\\/D0014\",\"style1\":null,\"vendor_style\":null,\"Parent_SKU\":\"\",\"upc\":\"609788050940\",\"desc\":\"Coveragfor First, Second Row Seats and Cargo Area Only\",\"notes\":\"Fits AllModels\",\"status\":\"1\",\"location\":null,\"warehouse\":\"\",\"listedamz\":null,\"listed_amazon1\":\"0\",\"amazon1_sku\":\"\",\"amazon1_asin\":\"\",\"amazon1_listing_id\":null,\"amazon1_price\":\"0\",\"amazon1_buffer\":\"0\",\"listed_amazon2\":\"0\",\"amazon2_sku\":null,\"amazon2_asin\":null,\"amazon2_listing_id\":null,\"amazon2_price\":\"0\",\"listed_walmart\":\"0\",\"walmart_sku\":\"\",\"walmart_listing_id\":\"\",\"walmart_buffer\":\"0\",\"walmart_price\":\"0\",\"amazon2_buffer\":\"0\",\"listed_ebay\":\"0\",\"ebay_sku\":\"\",\"ebay_listing_id\":\"\",\"ebay_price\":\"0\",\"ebay_buffer\":\"0\",\"ebay_category_id\":\"0\",\"listed_wish\":\"0\",\"wish_sku\":null,\"wish_listing_id\":null,\"wish_price\":\"0\",\"wish_buffer\":\"0\",\"listed_shopify1\":\"0\",\"shopify1_sku\":\"\",\"shopify1_listing_id\":\"\",\"shopify1_variant_id\":null,\"shopify1_inventory_item_id\":null,\"shopify1_location\":null,\"shopify1_price\":\"0\",\"shopify1_buffer\":\"0\",\"Bullet_Point_1\":\"\",\"Bullet_Point_2\":\"ALLWEATHER PROTECTION - All-weather, stain-resistant protection that gives your car, van, truck, or SUV interior a first class look while protecting its resale value.\",\"Bullet_Point_3\":\"CUSTOM FIT - The raised lip and custom designconstructed using innovative vehicle scanning technology ensures the perfect fit that protects your vehicle?s carpetfloor from the weather, spills and any messes.\",\"Bullet_Point_4\":\"EASY TO INSTALL & CLEAN - Textured, skid resistantsurface made from 100% recyclable materials offers 100% odorless protection that is easy to clean by hosing off or usingsoap and water.\",\"Bullet_Point_5\":\"LIFETIME WARRANTY - Strong, durable, easy to install, and backed by a limitedLifetime Warranty.\",\"Image1_URL\":\"https:\\\/\\\/www.maxtray.com\\\/media\\\/webimages\\\/A0021_B0021_D0014\\\/AMZ\\\/A0021_B0021_D0014.jpg\",\"Image2_URL\":\"\",\"Image3_URL\":\"\",\"Image4_URL\":\"\",\"Image5_URL\":\"\",\"qty\":\"0\",\"casepack\":\"1\",\"cost\":\"0\",\"landed_cost\":\"0\",\"price\":\"0\",\"prd_kit\":\"2\",\"kit_ship_settings\":\"1\",\"alertqty\":null,\"discontinued\":\"0\",\"one_per_box\":\"0\",\"box_size\":\"\",\"uom\":\"\",\"tags\":\"[\\\"\\\"]\",\"company\":\"0\",\"dim1\":\"48\",\"dim2\":\"32\",\"dim3\":\"6\",\"case_dim1\":\"0\",\"case_dim2\":\"0\",\"case_dim3\":\"0\",\"listed_sears\":\"0\",\"last_rec_in_main\":null,\"last_sent_fba\":null,\"wh_sell_price\":\"0\",\"retail_sell_price\":\"0\",\"prj_days\":\"7\",\"lead_time\":\"7\",\"oversized\":\"0\",\"case_weight\":\"\",\"case_upc\":\"\",\"prod_qty_per_pallet\":\"0\",\"invt_type\":\"0\",\"prod_type\":\"0\",\"date_created\":\"2022-01-1414:45:55\",\"aafes_buffer\":\"0\",\"aafes_listing_id\":null,\"aafes_price\":\"0\",\"aafes_sku\":null,\"amazon3_buffer\":\"0\",\"amazon3_listing_id\":null,\"amazon3_price\":\"0\",\"amazon3_sku\":null,\"amazon4_buffer\":\"0\",\"amazon4_listing_id\":null,\"amazon4_price\":\"0\",\"amazon4_sku\":null,\"amazondfca_asin\":null,\"amazondfca_buffer\":\"0\",\"amazondfca_listing_id\":null,\"amazondfca_price\":\"0\",\"amazondfca_sku\":null,\"amazondf_asin\":null,\"amazondf_buffer\":\"0\",\"amazondf_listing_id\":\"\",\"amazondf_price\":\"0\",\"amazondf_sku\":\"\",\"bbb_buffer\":\"0\",\"bbb_listing_id\":null,\"bbb_price\":\"0\",\"bbb_sku\":null,\"belk_buffer\":\"0\",\"belk_listing_id\":null,\"belk_price\":\"0\",\"belk_sku\":null,\"bestbuy_buffer\":\"0\",\"bestbuy_listing_id\":null,\"bestbuy_price\":\"0\",\"bestbuy_sku\":null,\"bjs_buffer\":\"0\",\"bjs_listing_id\":null,\"bjs_price\":\"0\",\"bjs_sku\":null,\"color\":null,\"dailysteals_listing_id\":null,\"dailysteals_price\":\"0\",\"dailysteals_sku\":null,\"domestify_buffer\":\"0\",\"domestify_listing_id\":null,\"domestify_price\":\"0\",\"domestify_sku\":null,\"groupon_buffer\":\"0\",\"groupon_listing_id\":null,\"groupon_price\":\"0\",\"groupon_sku\":null,\"home_depot_buffer\":\"0\",\"home_depot_listing_id\":null,\"home_depot_price\":\"0\",\"home_depot_sku\":null,\"hsn_buffer\":\"0\",\"hsn_listing_id\":null,\"hsn_price\":\"0\",\"hsn_sku\":null,\"jcpenney_buffer\":\"0\",\"jcpenney_listing_id\":null,\"jcpenney_price\":\"0\",\"jcpenney_sku\":null,\"kroger_buffer\":\"0\",\"kroger_listing_id\":null,\"kroger_price\":\"0\",\"kroger_sku\":null,\"listed_aafes\":\"0\",\"listed_amazon3\":\"0\",\"listed_amazon4\":\"0\",\"listed_amazondf\":\"0\",\"listed_amazondfca\":\"0\",\"listed_bbb\":\"0\",\"listed_belk\":\"0\",\"listed_bestbuy\":\"0\",\"listed_bjs\":\"0\",\"listed_dailysteals\":\"0\",\"listed_domestify\":\"0\",\"listed_groupon\":\"0\",\"listed_home_depot\":\"0\",\"listed_hsn\":\"0\",\"listed_jcpenney\":\"0\",\"listed_kroger\":\"0\",\"listed_lowes\":\"0\",\"listed_lowesca\":\"0\",\"listed_macys\":\"0\",\"listed_magento\":\"0\",\"listed_nordstrom\":\"0\",\"listed_qvc\":\"0\",\"listed_samsclub\":\"0\",\"listed_target\":\"0\",\"listed_tractorsupply\":\"0\",\"listed_walmartdsv\":\"0\",\"listed_zulily\":\"0\",\"lowesca_buffer\":\"0\",\"lowesca_listing_id\":null,\"lowesca_price\":\"0\",\"lowesca_sku\":null,\"lowes_buffer\":\"0\",\"lowes_listing_id\":null,\"lowes_price\":\"0\",\"lowes_sku\":null,\"macys_buffer\":\"0\",\"macys_listing_id\":null,\"macys_price\":\"0\",\"macys_sku\":null,\"magento_buffer\":\"0\",\"magento_listing_id\":null,\"magento_price\":\"0\",\"magento_sku\":null,\"nordstrom_buffer\":\"0\",\"nordstrom_listing_id\":null,\"nordstrom_price\":\"0\",\"nordstrom_sku\":null,\"qvc_buffer\":\"0\",\"qvc_listing_id\":null,\"qvc_price\":\"0\",\"qvc_sku\":null,\"samsclub_buffer\":\"0\",\"samsclub_listing_id\":null,\"samsclub_price\":\"0\",\"samsclub_sku\":null,\"sears_listing_id\":null,\"sears_price\":\"0\",\"sears_sku\":null,\"size\":null,\"target_buffer\":\"0\",\"target_listing_id\":null,\"target_price\":\"0\",\"target_sku\":null,\"tractorsupply_buffer\":\"0\",\"tractorsupply_listing_id\":null,\"tractorsupply_price\":\"0\",\"tractorsupply_sku\":null,\"walmartdsv_buffer\":\"0\",\"walmartdsv_listing_id\":null,\"walmartdsv_price\":\"0\",\"walmartdsv_sku\":null,\"zulily_buffer\":\"0\",\"zulily_listing_id\":null,\"zulily_price\":\"0\",\"zulily_sku\":null,\"zulily_upc\":null}"]}
print(json.dumps(json.loads(payload["products"][0]), indent=4))