Closed brianr closed 11 years ago
Thanks for the pull request!
I would like this module to behave just like the built-in JSON functions except they handle 64-bit integers and large decimals correctly. I am thinking we should just allow duplicate properties by default. What do you think?
Sounds good to me. I've updated the commit to make allowDuplicateProperties
default to true
.
Arg, this doesn't actually default to true
. Fix on the way.
No worries. Thanks for the pull request and fix.
While discouraged, the JSON spec does allow the same property to be present more than once in an object [1]. The built-in node.js JSON parser allows them, but json-bignum previously did not. This option (default false, same behavior as before) makes json-bignum behave the same way as JSON in this respect.
For example, consider the following JSON string:
{"hello": "world1", "hello": "world2"}
With
allowDuplicateProperties == false
, parsing above will throw a SyntaxError. Whentrue
, it will return:{"hello": "world2"}
Feedback welcome; I'm a little nervous sending this without any tests.
[1] See section 2.2: "The names within an object SHOULD be unique." http://www.ietf.org/rfc/rfc4627.txt