Your question is Efficient JSON Transformations. 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.
Palo Alto Networks frontend surfaces such as Cortex XSIAM may receive deeply nested JSON configuration and alert objects. Implement a function that removes every object field whose dot-separated path appears in a blocked-path list, including the field's entire subtree.
Given a JSON-compatible value data and an array blocked_paths, return a new JSON-compatible value with all matching fields removed. A path such as user.credentials.token refers only to object keys, and array elements do not add path components. Apply the same path rules independently to every object inside an array. Preserve the order of object keys and array elements. Do not mutate data.
Use a trie for blocked paths so shared prefixes are represented once and a blocked subtree can be skipped without traversing its descendants. Object keys used in paths do not contain periods. The root itself is never blocked.
def filter_json(data, blocked_paths):