Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use keyword in instead of hasOwnProperty to check if property exists #174

Open
ksimple opened this issue Jul 3, 2022 · 1 comment
Open

Comments

@ksimple
Copy link

ksimple commented Jul 3, 2022

Describe the bug

hasOwnProperty does not behave as the same as keyword in, it doesn't check the inheritance of property and doesn't check if propety whichi is in prototype

Code sample or steps to reproduce

// Code that reproduces problem here

function target() {
this.key1 = 1;
}

target.prototype.key2 = 2;

let obj = new target();

console.log(JSONPath({ path: '$.key1', json: obj }));
console.log(JSONPath({ path: '$.key2', json: obj }));

Console error or logs

[ 1 ]
[]

Expected behavior

[ 1 ]
[ 2 ]

Expected result

Environment (IMPORTANT)

  • JSONPath-Plus version: [e.g. 4.0.0]
    7.0.0

Desktop**

  • OS: [e.g. Windows]
  • Browser and version [e.g. chrome 65] or Node Version [e.g. 10.2]

Additional context

LoicMahieu added a commit to LoicMahieu/JSONPath that referenced this issue Aug 23, 2023
LoicMahieu added a commit to LoicMahieu/JSONPath that referenced this issue Aug 23, 2023
@brettz9
Copy link
Collaborator

brettz9 commented Aug 23, 2023

I think this should only be supported by opt-in configuration. Inheritance may more often be used to enhance an object without intending those methods to be used as data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants