Python 3 - How to convert a string to a list of dictionary

Shreyansh Lodha

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?

Mureinik

ast.literal_eval should do the trick:

from ast import literal_eval
result = literal_eval(my_string)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to convert values of a dictionary list into string?

How to convert List<string> to Dictionary<string,string> using linq?

How to convert a list of tuples to a dictionary of dictionaries in Python?

How to convert python list to python dictionary with sequence

How to convert String values in a dictionary to a list in python?

How to convert list of string to dictionary in python

Convert String representation of a List to a Dictionary Python

How to convert list of string to list of dictionary in Python

How to convert dictionary list to custom objects in Python

How to convert list to dictionary in python with key value?

how to convert list of dictionary into string python

Python - How to convert dictionary alike string to dictionary

How to convert string to dictionary into python

python dictionary and list: how to convert it?

Convert String to Python List of Dictionary

How convert list of dictionaries to a dictionary of dictionaries in Python

How to convert `Dictionary<string, Dictionary<string, List<MyCustomClass>>>` to `Dictionary<string, List<MyCustomClass>> `

How to convert list of list to dictionary in Python?

convert unequaled length list of string to dictionary python

How to convert a unicode list to a list containing python dictionary in python 2.x and 3.x

How to convert unciode to list of dictionary in python

how to convert string list dictionary to list

How do I convert list into dictionary in Python?

How to convert a String to a dictionary list

How to convert nested dictionary into the string of list

How to convert String to list in Python 3

how to convert a list to dictionary in python?

How to convert a string dictionary to dictionary in python?

How to convert list to dictionary in Python?