Open klesun opened 3 years ago
Anything stopping this being merged??
Anything stopping this being merged??
Ah because it doesn't actually do anything! The 'objectBaseClass' option isn't actually applied to the _options
variable that parse
reads from.
I've just opened #64 with a similar fix. It won't let you provide an arbitrary prototype for the parsed objects, but it will let you choose between Object.create(null)
and {}
.
As discussed in https://github.com/sidorares/json-bigint/issues/38, after the c85a4300aa0159ce1859c1b1adfdac9e515e5396 (
v1.0.0
) base class for parsed objects is nownull
rather thanObject
. This differs from theJSON.parse()
behaviour and breaks compatibility for codebases that are using prototype methods likehasOwnProperty()
.By specifying the
objectBaseClass
option introduced in this PR, users of the lib will be able to use it even in a code that relies on parsed object to havehasOwnProperty
,toString
and other prototype methods:Closes #39, #38