-
Notifications
You must be signed in to change notification settings - Fork 4
Strings with leading 0s are accepted but produce invalid JSON #6
Copy link
Copy link
Open
Description
i.e.
const bignumJSON = require('json-bignum')
> bignumJSON.stringify({key: new bignumJSON.BigNumber("0123")})
'{"key":0123}'
> JSON.parse(bignumJSON.stringify({key: new bignumJSON.BigNumber("0123")}))
SyntaxError: Unexpected number in JSON at position 8I know the bug is mainly in the code using json-bignum but by allow invalid JSON to be produced the bug is allowed to propagate into other systems.. Perhaps strings with leading 0s should be rejected with an exception in the BigNumber constructor?
Line 11 in 68f270d
| throw new Error(number + ' is not a number'); |
BTW, thanks very much for this simple & effective package.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels