Your question is Recursion Over Nested Data. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Klaviyo event payloads can contain nested objects and arrays, such as profile properties, product details, and line items. Implement a recursive function that flattens a JSON-compatible payload into a dictionary of paths to scalar values.
Given payload, a JSON-compatible Python dictionary or list, return a dictionary where:
None, becomes one output entry...For example, {"customer": {"email": "a@example.com"}} becomes {"customer.email": "a@example.com"}.
.def flatten_event_payload(payload):