Reputation: 239
I'm having trouble using a list that is represented in unicode. I've tried looking at other questions and the json.dumps() function shows a u'string' but it isn't the case for me. I can't iterate over the list because python sees the whole thing as a string and gives me individual chars. Here is some code.
print flist
print type(flist)
['a', 'b', 'c']
<type 'unicode'>
myjson = json.dumps(flist)
print myjson
print type(myjson)
"['a', 'b', 'c']"
<type 'str'>
Shouldn't it be? :
[u'a', u'b', u'c']
Upvotes: 0
Views: 183
Reputation: 90979
Try ast.literal_eval
import ast
ast.literal_eval(flist.decode())
Upvotes: 1