Given a messy JSON payload of user application data at Bestow, write a Python script to flatten, clean, and validate the records.
Implement process_applications(payload). The input is a dictionary with an applications list. Normalize keys to lowercase snake case, flatten nested objects with dot-separated keys, trim strings, convert blank strings to None, and preserve cleaned lists. Return {"valid": [...], "invalid": [...]}. Valid records must contain a nonempty application_id, a valid email, and an integer age from 18 through 100. Invalid records contain the zero-based index and an ordered list of error messages.
payload contains an applications list.def process_applications(payload):