python : unable to turn json string to json dict

im trying to have this code return type dict from string I tried using

import json

box_of_cookies = "{'domain': '.kith.com', 'expiry': 1662402888, 'httpOnly': False, 'name': 'geolizr_geodata', 'path': '/', 'sameSite': 'Strict', 'secure': True, 'value': '{%22as%22:%22AS701%20MCI%20Communications%20Services%2C%20Inc.%20d/b/a%20Verizon%20Business%22%2C%22asname%22:%22UUNET%22%2C%22mobile%22:false%2C%22proxy%22:false%2C%22city%22:%22East%20Orange%22%2C%22currency%22:{%22code%22:%22USD%22}%2C%22country%22:{%22code%22:%22US%22%2C%22country%22:%22United%20States%22}%2C%22countryCode%22:%22US%22%2C%22continent%22:%22North%20America%22%2C%22continentCode%22:%22NA%22%2C%22isp%22:%22MCI%20Communications%20Services%2C%20Inc.%20d/b/a%20Verizon%20Business%22%2C%22lat%22:40.7523%2C%22lon%22:-74.2172%2C%22org%22:%22Verizon%20Communications%22%2C%22query%22:%2274.102.170.52%22%2C%22region%22:%22NJ%22%2C%22regionName%22:%22New%20Jersey%22%2C%22status%22:%22success%22%2C%22timezone%22:%22America/New_York%22%2C%22zip%22:%2207018%22%2C%22cloudflare%22:%22US%22%2C%22ttl%22:2399%2C%22env%22:%22PROD%22%2C%22version%22:%22ip-api%20cached%22%2C%22currencyCode%22:%22USD%22%2C%22countryName%22:%22United%20States%22%2C%22service%22:%22ip.lovely-app.com%22}'}, {'domain': '.kith.com', 'expiry': 1630868688, 'httpOnly': False, 'name': '_shopify_sa_t', 'path': '/', 'sameSite': 'Lax', 'secure': False, 'value': '2021-09-05T18%3A34%3A48.213Z'}, {'domain': 'kith.com', 'expiry': 1693938888, 'httpOnly': False, 'name': '__kla_id', 'path': '/', 'secure': False, 'value': 'eyIkcmVmZXJyZXIiOnsidHMiOjE2MzA4NjY4ODYsInZhbHVlIjoiIiwiZmlyc3RfcGFnZSI6Imh0dHBzOi8va2l0aC5jb20vYWNjb3VudC9sb2dpbiJ9LCIkbGFzdF9yZWZlcnJlciI6eyJ0cyI6MTYzMDg2Njg4OCwidmFsdWUiOiIiLCJmaXJzdF9wYWdlIjoiaHR0cHM6Ly9raXRoLmNvbS9hY2NvdW50L2xvZ2luIn19'}, {'domain': 'kith.com', 'expiry': 1662402887, 'httpOnly': True, 'name': 'secure_customer_sig', 'path': '/', 'secure': True, 'value': 'e2f7a59a5aec576e527d7240d1db9f7b'}, {'domain': '.kith.com', 'expiry': 1630868688, 'httpOnly': False, 'name': '_shopify_sa_p', 'path': '/', 'sameSite': 'Lax', 'secure': False, 'value': ''}, {'domain': 'kith.com', 'expiry': 1632076486, 'httpOnly': True, 'name': 'cart_sig', 'path': '/', 'sameSite': 'None', 'secure': True, 'value': '90d14af23f488d1426f499a12b8cfd28'}, {'domain': 'kith.com', 'expiry': 1662402888, 'httpOnly': False, 'name': 'KL_FORMS_MODAL', 'path': '/', 'secure': False, 'value': '{%22disabledForms%22:{}%2C%22viewedForms%22:{%22TFUkCm%22:3408578}}'}, {'domain': '.kith.com', 'expiry': 1630866945, 'httpOnly': False, 'name': '_gat_gtag_UA_62344036_3', 'path': '/', 'secure': False, 'value': '1'}, {'domain': 'kith.com', 'expiry': 1630953287, 'httpOnly': True, 'name': '_secure_session_id', 'path': '/', 'sameSite': 'None', 'secure': True, 'value': '0c1901c20ab9506de47abaa56ee3ee11'}, {'domain': '.kith.com', 'expiry': 1630868688, 'httpOnly': False, 'name': '_shopify_s', 'path': '/', 'sameSite': 'Lax', 'secure': False, 'value': 'e6c34f1d-6eb1-4fda-a683-fe9c7428f49e'}, {'domain': 'kith.com', 'expiry': 1630870486, 'httpOnly': False, 'name': 'shopify_pay_redirect', 'path': '/', 'secure': False, 'value': 'pending'}, {'domain': '.kith.com', 'expiry': 1662402887, 'httpOnly': False, 'name': '_y', 'path': '/', 'sameSite': 'Lax', 'secure': False, 'value': 'cab0fbd3-25c8-4939-949f-441b5eacb116'}, {'domain': '.kith.com', 'expiry': 1630953288, 'httpOnly': False, 'name': '_gid', 'path': '/', 'secure': False, 'value': 'GA1.2.1460112824.1630866886'}, {'domain': 'kith.com', 'expiry': 1630868687, 'httpOnly': False, 'name': 'dynamic_checkout_shown_on_cart', 'path': '/', 'secure': False, 'value': '1'}, {'domain': '.kith.com', 'expiry': 1662402887, 'httpOnly': False, 'name': '_shopify_y', 'path': '/', 'sameSite': 'Lax', 'secure': False, 'value': 'cab0fbd3-25c8-4939-949f-441b5eacb116'}, {'domain': 'kith.com', 'expiry': 1630868684, 'httpOnly': False, 'name': '_shopify_country', 'path': '/', 'secure': False, 'value': 'United+States'}, {'domain': '.kith.com', 'expiry': 1632076484, 'httpOnly': True, 'name': '_landing_page', 'path': '/', 'sameSite': 'Lax', 'secure': False, 'value': '%2Faccount%2Flogin'}, {'domain': 'kith.com', 'httpOnly': False, 'name': 'snize-recommendation', 'path': '/', 'secure': False, 'value': '3s53e71zpk6'}, {'domain': '.kith.com', 'expiry': 1693938886, 'httpOnly': False, 'name': 'GlobalE_CT_Data', 'path': '/', 'sameSite': 'Lax', 'secure': False, 'value': '%7B%22CUID%22%3A%22561504970.682656459.583%22%2C%22CHKCUID%22%3Anull%7D'}, {'domain': '.kith.com', 'expiry': 1630868688, 'httpOnly': False, 'name': '_s', 'path': '/', 'sameSite': 'Lax', 'secure': False, 'value': 'e6c34f1d-6eb1-4fda-a683-fe9c7428f49e'}, {'domain': '.kith.com', 'expiry': 1632076484, 'httpOnly': True, 'name': '_orig_referrer', 'path': '/', 'sameSite': 'Lax', 'secure': False, 'value': ''}, {'domain': '.kith.com', 'expiry': 1662402889, 'httpOnly': False, 'name': '__zlcmid', 'path': '/', 'sameSite': 'Lax', 'secure': False, 'value': '15vkJEQAVa9KC2y'}, {'domain': '.kith.com', 'httpOnly': False, 'name': 'GlobalE_SupportThirdPartCookies', 'path': '/', 'secure': False, 'value': 'true'}, {'domain': '.kith.com', 'expiry': 1631126086, 'httpOnly': False, 'name': 'GlobalE_Data', 'path': '/', 'secure': False, 'value': '%7B%22countryISO%22%3A%22US%22%2C%22currencyCode%22%3A%22USD%22%2C%22cultureCode%22%3A%22en-US%22%7D'}, {'domain': '.kith.com', 'expiry': 1630866945, 'httpOnly': False, 'name': '_gat', 'path': '/', 'secure': False, 'value': '1'}, {'domain': 'kith.com', 'expiry': 1632076487, 'httpOnly': False, 'name': 'cart_currency', 'path': '/', 'secure': False, 'value': 'USD'}, {'domain': '.kith.com', 'httpOnly': False, 'name': 'GlobalE_Full_Redirect', 'path': '/', 'sameSite': 'Lax', 'secure': False, 'value': 'false'}, {'domain': '.kith.com', 'expiry': 1693938888, 'httpOnly': False, 'name': '_ga', 'path': '/', 'secure': False, 'value': 'GA1.2.797558024.1630866886'}"


#adds cookie to driver
def parse_Cookie_string(box_of_cookies):
    #print(cookie.split("},"))
    cookies_list = list(box_of_cookies.split("},"))
    for cookie in cookies_list:
        #check if its the last number element in the list if it is dont add the }
        if(cookie == cookies_list[-1]):
            pass
        else:
            cookie += "}" 
        
        
        print("{}n".format(type(box_of_cookies)))
        #driver.add_cookie(cookie)

ive tried adding putting json.loads(box_of_cookies) but its juts ends up giving me a error saying

Expecting value: line 1 column 59 (char 58)

Answer

The True and False must be lowercase, and JSON must be one object; the multiple objects must be placed inside an array. To rectify this, place the following code after the string (as an example) to alter the JSON to make it valid. The code is not exhaustive, but will work for these circumstances.

box_of_cookies = box_of_cookies.replace('False', 'false')
box_of_cookies = box_of_cookies.replace('True', 'true')
box_of_cookies = '[' + box_of_cookies + ']'
box_of_cookies = box_of_cookies.replace(''', '"')

Then, the json.loads() should work as expected.