How to Parse Json Keys from Repose or External json

I am not able to find any function or code snippets to fetch the keys (not data or value) from the response and compare with the keys of an external json.
If I have a requirement of comparing the keys between external json and response then how should I do it.
Example : The external json has client id, Salary, age where as the repose send client id , Salary, gender and Age then the test code should be able to generate errors for Gender as this is not expected in the response.
Lets say I have external json schema as
“data”: {
“id”: " ",
“first_name”: " ",
“last_name”: " ",
“avatar”: " "

Now if i wanted to compare each key like ‘id’ to see if it exists within response to see if it present in response or not.So my question are below

  1. How to read the external json using test code
  2. How to extract keys from that json
  3. how to compare with the response keys
    I am intending to do it dynamically so that can reuse the same script for any other API testing

Did you try using the JSON schema validation?

Json schema validation t4.validate will only the type of keys (properties) but not check the property will show as passed even though external json and response has different number of properties.

If you mean something else then can post the code here.