Reputation: 3895
I am trying to convert
list1=["{\"username\":\"abhi\",\"pass\":2087}"]
to
list1=[{"username":"abhi","pass":2087}]
Is there any way to do it without lots of splitting and creating dictionary and then putting into list?
Upvotes: 1
Views: 92
Reputation: 2804
You can parse it as a JSON string.
import json
list2 = [json.loads(item) for item in list1]
Output -
[{u'pass': 2087, u'username': u'abhi'}]
Upvotes: 6