Reputation: 4666
I have a list like:
"subItems": [{"orderId": "OD303682818269056101","shippingFee": 0.0, "hold": False,
"orderDate": "2015-08-19T13:57:48+05:30", "quantity": 1}]
i want to convert it to dict like:
new_dict = {"orderId": "OD303682818269056101",
"shippingFee": 0.0,
"hold": False,
"orderDate": "2015-08-19T13:57:48+05:30",
"quantity": 1}
how to do that?
I tried
dict(subItems)
but didn't worked.
Upvotes: 0
Views: 356
Reputation: 2592
It already is a dictionary, inside a list, at the first index (index 0). To access the dictionary, you simply need to get the first item (at index 0). To get the first item of any list you use the syntax L[0]
so this is what you need:
new_dict = subItems[0]
Upvotes: 1