Your question is Traverse and Transform Nested JSON. 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.
lululemon product attributes and order metadata can contain deeply nested JSON objects and arrays. Implement an algorithm that transforms this JSON into a flat dictionary containing one entry for every non-null primitive value.
Implement flatten_metadata(data), where data is a JSON-compatible object containing dictionaries, lists, strings, numbers, booleans, and null. Return a dictionary mapping each leaf's path to its primitive value.
Use these path rules:
..items[0].sku.\\ as \\\\ and . as \\. before joining paths.null values and empty dictionaries or lists.def flatten_metadata(data):