I am attempting to convert the following dict into JSON using json.dumps:
{
\'post_engaged\': 36,
\'post_impressions\':
You could try to clean it up like this:
for key in mydict.keys():
if type(key) is not str:
try:
mydict[str(key)] = mydict[key]
except:
try:
mydict[repr(key)] = mydict[key]
except:
pass
del mydict[key]
This will try to convert any key that is not a string into a string. Any key that could not be converted into a string or represented as a string will be deleted.