How do I convert this string ->
string = [{"name":"sam"}]
into a python dictionary like so ->
data = {
"name" : "sam"
}
In [1]: import json
In [2]: json.loads('[{"name":"sam"}]')
Out[2]: [{u'name': u'sam'}]
This returns a list, the first element of which is the desired dictionary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With