python json转换异常:“In order to allow non-dict objects to be serialized..."
来源:互联网 发布:臭苋菜 知乎 编辑:程序博客网 时间:2024/06/17 02:00
看 JsonResponse(HttpResponse)类源码:知道是传入的数据不是字典类型,改为字典类型即可
def __init__(self, data, encoder=DjangoJSONEncoder, safe=True,
json_dumps_params=None, **kwargs):
if safe and not isinstance(data, dict):
raise TypeError(
'In order to allow non-dict objects to be serialized set the '
'safe parameter to False.'
)
if json_dumps_params is None:
json_dumps_param
s = {}
kwargs.setdefault('content_type', 'application/json')
data = json.dumps(data, cls=encoder, **json_dumps_params)
super(JsonResponse, self).__init__(content=data, **kwargs)
def __init__(self, data, encoder=DjangoJSONEncoder, safe=True,
json_dumps_params=None, **kwargs):
if safe and not isinstance(data, dict):
raise TypeError(
'In order to allow non-dict objects to be serialized set the '
'safe parameter to False.'
)
if json_dumps_params is None:
json_dumps_param
s = {}
kwargs.setdefault('content_type', 'application/json')
data = json.dumps(data, cls=encoder, **json_dumps_params)
super(JsonResponse, self).__init__(content=data, **kwargs)
0 0
- python json转换异常:“In order to allow non-dict objects to be serialized..."
- Django 调试时提示: In order to allow non-dict objects to be serialized
- dict to json And json to dict
- json to dict
- In order to be irreplaceable, one must always be different.
- python dict to dataframe
- Convert objects to JSON in C# using JavaScriptSerializer
- Convert objects to JSON in C# using JavaScriptSerializer
- In order to understandC++
- python dict与json转换
- Allow a different JSF implementation to be packaged in the WAR
- 异常信息:No Hibernate Session bound to thread, and configuration does not allow creation of non-transact
- christian louboutin soldes in order to let our conscience be able to secure
- jre or jdk must be available in order to run javaw.exe in your current path
- In order to understand C++
- Overlay permissions needs to be granted in order for react native apps to run in dev mode
- Add Additional Objects to JSON Encoded Array
- python中将json字符串转换为dict
- Django深入模板引擎
- 自己封装的web请求
- cron表达式详解
- vc2010编译错误atlcore.h(35): fatal error C1189
- LNMP以及LAMP的解释说明(系统名词普及)
- python json转换异常:“In order to allow non-dict objects to be serialized..."
- iOS开发中pch文件的使用误区探讨
- easyui combobox
- Android RecyclerView 使用完全解析 体验艺术般的控件
- android开发之工具类:获取手机设备的一些数据DeviceUtil
- 队列
- Centos6.8安装CKAN2.5.2的安装指南
- 人月神话读书笔记(3)----外科手术队伍
- [LeetCode] 8. String to Integer (atoi)