I have unicode u\"{\'code1\':1,\'code2\':1}\"
and I want it in dictionary format.
I want it in {\'code1\':1,\'code2\':1}
format.
I
I was getting unicode error when I was reading a json from a file. So this one worked for me.
import ast
job1 = {}
with open('hostdata2.json') as f:
job1= json.loads(f.read())
f.close()
#print type before converting this from unicode to dic would be
print type(job1)
job1 = ast.literal_eval(job1)
print "printing type after ast"
print type(job1)
# this should result
for each in job1:
print each
print "printing keys"
print job1.keys()
print "printing values"
print job1.values()