try: qByUser = byUsrUrlObj.read() qUserData = json.loads(qByUser).decode('utf-8') questionSubjs = qUserData["all"]["questions"] except ValueError: # includes simplejson.decoder.JSONDecodeError print('Decoding JSON has failed')