Your question is Implementing a JSON Field Based on ID. 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.
GoFundMe payloads can contain nested campaign, reward, and donation items represented by JSON objects and arrays. Given a JSON-compatible value, return a new value where every object containing an integer id also contains an isEven field set to true when the ID is even and false otherwise.
Do not mutate the input. Preserve object fields, array order, and primitive values. If an object already contains isEven, replace it with the value derived from id. Objects without an id must remain structurally unchanged, but their nested values must still be processed.
Implement annotate_items(payload), where payload is a JSON value composed only of dictionaries, arrays, strings, numbers, booleans, and null. Return a new JSON value with the same structure and the required annotations.
def annotate_items(payload):