Your question is Render Dynamic Card From API. 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.
Implement a function that takes a JSON string returned by a mock API and converts it into a normalized card object with four required fields: heading, subheading, summary, and image. The input may contain extra fields, missing fields, or invalid JSON. Return the normalized object when valid, or null when the payload cannot produce a complete card.
title, subtitle, description, and imageUrlnull for invalid JSON or missing/empty required fieldsdef parse_card_payload(payload):