jsonlint
jsonlint copied to clipboard
Property named `hasOwnProperty` breaks `jsonlint --sort-keys`
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?
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.