My goal is to write the response I get from a call to Amazon's Product Advertising API to a file in JSON format.
I call the API using
response = default_api.search_items(search_items_request)
I attempt to write the results to a file using:
with open('data.json', 'w') as f:
json.dump(response, f)
I get the error message:
TypeError : Object of type 'SearchItemsResponse' is not JSON serializable
How can I fix this? I need to write the response in JSON. A solution is greatly appreciated.