Your question is Flatten Nested Config Dictionary. 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.
At Meta, infrastructure and service configs are often represented as nested JSON-like dictionaries. Write a function that flattens a nested dictionary into a single-level dictionary using dot-separated key paths.
Given a dictionary where values may be primitives or other dictionaries, return a new dictionary mapping each leaf value to its full path. If a value is not a dictionary, it is a leaf and should appear in the output. Use . to join nested keys.
obj, a Python dictionary with string keys. Values may be strings, numbers, booleans, null-like values, lists, or nested dictionaries.def flatten_dict(obj):