Python Rest API Data Transformation
Implement transform_response(payload) to flatten a JSON API response. The input contains a data list of objects with id, attributes, and optional relationships. Return records containing the ID, copied attributes, and relationship IDs. A to-one relationship becomes <name>_id; a to-many relationship becomes <name>_ids. Preserve input order and omit relationships whose data is null.
data listidid, or a list of such objectsid or generated relationship fieldsdef transform_response(payload):