Write a script to clean, transform, and normalize nested JSON payload data from a simulated Uber Eats order event stream.
Implement normalize_order_events(events). Trim string identifiers, lowercase statuses, uppercase currencies, convert valid monetary values to integer cents using half-up rounding, and aggregate valid duplicate items by ID. Skip events without an order ID and invalid items. Return one normalized object per valid order with missing scalar values represented by null.
Input is a list of JSON objects. Each output object contains event_id, order_id, status, customer_id, total_cents, currency, and items; each item contains item_id, name, quantity, and unit_price_cents.
payload objectiddef normalize_order_events(events):