In a Capgemini API testing workflow, an automated check must verify selected data points in a JSON response. Implement a function that confirms every requested path exists and contains the expected value, including values nested inside dictionaries and lists.
Write validate_response(response, checks).
response is a JSON-compatible Python object containing dictionaries, lists, strings, numbers, booleans, or None.checks is a list of dictionaries. Each dictionary contains:
path: a non-empty list of string dictionary keys or integer list indexes.expected: the required value at that path.True only when every path exists and its value equals expected with the same Python type. For example, True must not match 1.False if a path is missing, an index is invalid, an intermediate value has the wrong container type, or any value does not match.checks list is valid and should return True.def validate_response(response, checks):