jsonlint icon indicating copy to clipboard operation
jsonlint copied to clipboard

Property named `hasOwnProperty` breaks `jsonlint --sort-keys`

Open paparomeo opened this issue 8 years ago • 1 comments

Running on the shell:

echo '{"hasOwnProperty":true}' | jsonlint --sort-keys

results in the following error:

[TypeError: Property 'hasOwnProperty' of object #<Object> is not a function]

Could this also be happening for other Object.prototype properties?

paparomeo avatar Apr 17 '16 19:04 paparomeo

I needed some bugfixes and extensions to jsonlint and did them in my fork. I released the changes as a new NPM module @prantlf/jsonlint. Fixing the problem with properties named "hasOwnProperty" was one of them.

Only the "hasOwnProperty" name caused problems. The hasOwnProperty method was the only one, which was tried to be called on objects parsed from the JSON input.

prantlf avatar May 19 '19 04:05 prantlf