我有一个数据列表,每个元素都是这种格式
{
"Account_Level": 143,
"ActiveId1": 8844,
"ActiveId2": 8879,
"ActiveId3": 0,
"ActiveId4": 0,
"Assists": 14,
"ret_msg": null
}
此数据是从API包装中提取的,因此类型为pyrez.models.Match.Match
,因此在尝试使用json.dump
保存包含此类型数据的列表时
TypeError: Object of type Match is not JSON serializable
编辑:通过单独更改每个元素来修复[i.json for i in session]
看起来这个PyRez库为API响应使用了某种自定义Dict对象,并且
__str__
方法已经在执行参数的json.dump
。所以试试str(the_obj)
。见here相关问题 更多 >
编程相关推荐