prantlf / jsonlint

JSON/CJSON/JSON5 parser, syntax & schema validator and pretty-printer with a command-line client, written in pure JavaScript.
http://prantlf.github.io/jsonlint/
MIT License
37 stars 9 forks source link

Don't ignore duplicate keys with the following values: "", 0, false, null #24

Closed karlex closed 2 months ago

karlex commented 1 year ago

Don't ignore duplicate keys with the following values: "", 0, false, null. And don't throw errors on keys equal to keys in Object.prototype like "constructor".

prantlf commented 2 months ago

Thank you for your contribution! I'm sorry, I haven't merged your change. I made this change using hasOwnProperty from Object.prototype. Well, there's no difference, because the object result has just been created empty, but it calms the linters down. Actually, I'm going to eventually replace it with the new Object.hasOwn.

This problem was reported by #23 in the meanwhile. I fixed it in in 14.1.0, commit b357141820cf19be227342ea944f8c3208ec865.

The original code omitted every key from Object.prototype. It was too harsh even for prevention of the prototype pollution (__proto__ key). I added some more options to re-enable the previous behaviour or omit just the __proto__ key in 15.0.0, commit e2f8a7be3cdb78bf696ba4251e2b3053f5714c22.

Thank you for you help!