将 Dropbox class 转换为 JSON
Cast Dropbox class to JSON
我正在使用 Python Dropbox 软件包来拉动团队活动:
dbx = dropbox.DropboxTeam(self.access_token)
result = dbx.team_log_get_events()
我需要将 result
的值作为 JSON 对象传递。当我尝试使用 json.dumps(result)
时,出现此错误:
TypeError: Object of type GetTeamEventsResult is not JSON serializable
有没有办法使用 Dropbox 包转换为 json/dict?
我的其他潜在解决方案是编写我自己的方法来转换它(看起来很乏味)或者只是进行 API 调用而不是使用包。
刚刚收到 DB 论坛上 Dropbox 开发人员的回复:
The methods for calling the API in the Dropbox Python SDK don't return JSON-serializable objects (or the original JSON from the server), but I'll pass this along as a feature request. I can't promise if or when that might be implemented though.
You can transform the information in the returned native object however you wish, but you'd need to write the code to do so though unfortunately, as you mentioned.
如果有更多信息出现,将保持此 post 更新。
我正在使用 Python Dropbox 软件包来拉动团队活动:
dbx = dropbox.DropboxTeam(self.access_token)
result = dbx.team_log_get_events()
我需要将 result
的值作为 JSON 对象传递。当我尝试使用 json.dumps(result)
时,出现此错误:
TypeError: Object of type GetTeamEventsResult is not JSON serializable
有没有办法使用 Dropbox 包转换为 json/dict?
我的其他潜在解决方案是编写我自己的方法来转换它(看起来很乏味)或者只是进行 API 调用而不是使用包。
刚刚收到 DB 论坛上 Dropbox 开发人员的回复:
The methods for calling the API in the Dropbox Python SDK don't return JSON-serializable objects (or the original JSON from the server), but I'll pass this along as a feature request. I can't promise if or when that might be implemented though.
You can transform the information in the returned native object however you wish, but you'd need to write the code to do so though unfortunately, as you mentioned.
如果有更多信息出现,将保持此 post 更新。