Reputation: 83
I have the data coming as a API which is in a string format And the data is exactly like list of dictionaries
'{'key1':'value','key2':'value','key3':'value'},{'key1':'value','key2':'value','key3':'value'},...'
Is their any way I can convert this string to a list of dictionary?
Upvotes: 0
Views: 933
Reputation: 312146
ast.literal_eval
should do the trick:
from ast import literal_eval
result = literal_eval(my_string)
Upvotes: 1