Converting JSON into Python dict
Posted
by GrumpyCanuck
on Stack Overflow
See other posts from Stack Overflow
or by GrumpyCanuck
Published on 2010-03-21T03:38:29Z
Indexed on
2010/03/21
3:41 UTC
Read the original article
Hit count: 601
I've been searching around trying to find an answer to this question, and I can't seem to track it down. Maybe it's too late in the evening to figure the answer out, so I turn to the excellent readers here.
I have the following bit of JSON data that I am pulling out of a CouchDB record:
"{\"description\":\"fdsafsa\",\"order\":\"1\",\"place\":\"22 Plainsman Rd, Mississauga, ON, Canada\",\"lat\":43.5969175,\"lng\":-79.7248744,\"locationDate\":\"03/24/2010\"},{\"description\":\"sadfdsa\",\"order\":\"2\",\"place\":\"50 Dawnridge Trail, Brampton, ON, Canada\",\"lat\":43.7304774,\"lng\":-79.8055435,\"locationDate\":\"03/26/2010\"},"
This data is stored inside a Python dict under the key 'locations' in a dict called 'my_plan'. I want to covert this data from CouchDB into a Python dict so I can do the following in a Django template:
{% for location in my_plan.locations %}
<tr>
<td>{{ location.place }}</td>
<td>{{ location.locationDate }}</td>
</tr>
{% endfor %}
I've found lots of info on converting dicts to JSON, but nothing on going back the other way
Thanks in advance for the help!
© Stack Overflow or respective owner