I am trying to decode a dict of base64 strings like this:
responses64 = {
'54sdf61': 'eyJyZXNwb2...',
'23423vse': 'sdfwerfwewe...'
}
The data comes like this from an API query, so I can't change that part.
Normally, I'd do this to decode base64:
response = json.loads(base64.b64decode(response64))
But since I have adict now with many of these strings, I have go another way. The best I could come up with was a for-loop over the key values, which are stored in another list called IDs
, and write the results into a dict:
responses = {}
for i in IDs:
responses[i] = json.loads(base64.b64decode(responses64[i]))
However, this doesn't work, since b64decode doesn't like to operate on dicts:
TypeError: argument should be a bytes-like object or ASCII string, not 'dict'
Any idea would be appreciated...