相关疑难解决方法(0)

将JSON转换为Python dict

我一直在寻找这个问题的答案,而我似乎无法追踪它.也许晚上来得太晚才能找出答案,所以我在这里转向优秀的读者.

我有以下一些JSON数据,我从CouchDB记录中提取出来:

"{\"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\"},"
Run Code Online (Sandbox Code Playgroud)

这些数据存储在Python dict locations中,位于名为' my_plan' 的dict中的键' ' 下.我想将这些数据从CouchDB转换为Python dict,所以我可以在Django模板中执行以下操作:

{% for location in my_plan.locations %}                                                           
<tr>
    <td>{{ location.place }}</td>
    <td>{{ location.locationDate }}</td>
</tr>

{% endfor %}
Run Code Online (Sandbox Code Playgroud)

我已经找到了很多关于将dicts转换为JSON的信息,但是没有其他方面可以反过来.

python django json dictionary

23
推荐指数
2
解决办法
6万
查看次数

标签 统计

dictionary ×1

django ×1

json ×1

python ×1