python - 如何在 django python 中用 json 替换 simplejson?

标签 python django

我的 View 中有以下代码:

def __init__(self, obj='', json_opts={}, mimetype="application/json", *args, **kwargs):
        content = simplejson.dumps(obj, **json_opts)
        super(JSONResponse, self).__init__(content, mimetype, *args, **kwargs)

由于 simplejson 将被弃用,我可以使用它吗

content = json.dumps(obj, **json_opts)

还是我需要做更多?

最佳答案

改用python的json:

Django 1.5 release notes

import json

关于python - 如何在 django python 中用 json 替换 simplejson?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13005383/

相关文章:

python - Tweepy 引用状态 "Status has no attribute quoted_status"

python - 在 Django 1.6 中编辑表单

python - django 中的 _lte、__name、__startswith 等查询 - 记录在哪里?

python - 使用 Django,如何从父类(super class)对象实例构造代理对象实例?

python - PyCharm 4.5 ReStructuredText 支持打破空格、换行符、制表符等

python - 字符串转换为干净的 int 列表

python - 无法让 Web.py 和 jQuery 计算出 AJAX GET 请求(它变成了 OPTIONS 请求)

python - 计算图像中的绿色百分比

javascript - 下载按钮重定向到错误页面

django - 如何将 "class"添加到 Django 中的 ChoiceField?