我的目标是将调用亚马逊产品广告 API 得到的响应写入 JSON 格式的文件。
我使用调用 API
response = default_api.search_items(search_items_request)
我尝试使用以下方法将结果写入文件:
with open('data.json', 'w') as f:
json.dump(response, f)
我收到错误消息:
TypeError : Object of type 'SearchItemsResponse' is not JSON serializable
我怎样才能解决这个问题?我需要用 JSON 编写响应。非常感谢一个解决方案。