Thanks all. I have read the doc link from @Yann Vernier. This is what I was looking for.
s = '[1,3,4]'
j = json.JSONDecoder()
l =j.decode(s)
– palazzo trainOct 21 '16 at 10:10
The answer in http://stackoverflow.com/questions/4528099/convert-string-to-json-using-python is not the answer of this question. I just find that the correct answer should be json.JSONDecoder().decode( '[1,2,3]' ). But I cannot click the answer now.
– palazzo trainOct 21 '16 at 10:14
@PadraicCunningham, my bad, json.loads does actually work. I thought you always need the field name in the string for loads function.
– palazzo trainOct 22 '16 at 14:46
1 Answers1
2
You can use the json module:
import json
s = '[1, 2, 3]'
json_as_list = json.loads(s)