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

我的观点中包含以下代码: def __init__(self, obj=, json_opts={}, mimetype=application/json, *args, **kwargs): content = simplejson.dumps(obj, **json_opts) super(JSONResponse, self).__init__(con

我的观点中包含以下代码:

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

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

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

还是我需要做更多?

解决方法

根据
this answer,json是simplejson.但是,根据这个
release note,可能会有一些
incompatibilities,具体取决于您当前使用的simplejson版本.无论哪种方式,您都希望在某些时候用json替换simplejson.只需确保在将代码推送到生产环境之前对其进行测试.

作者: dawei

【声明】:西安站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。

为您推荐

联系我们

联系我们

0577-28828765

在线咨询: QQ交谈

邮箱: xwei067@foxmail.com

工作时间:周一至周五,9:00-17:30,节假日休息

返回顶部