We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSONbig.stringify escapes '\u202c' while JSON.stringify does not:
JSONbig.stringify
JSON.stringify
Welcome to Node.js v16.20.0. Type ".help" for more information. > JSONbig = require('json-bigint') [Function (anonymous)] { parse: [Function (anonymous)], stringify: [Function (anonymous)] } > x = { k: 'a\u202cz' } { k: 'az' } > [...JSON.stringify(x)].map(i => i.charCodeAt(0).toString(16)) [ '7b', '22', '6b', '22', '3a', '22', '61', '202c', '7a', '22', '7d' ] > [...JSONbig.stringify(x)].map(i => i.charCodeAt(0).toString(16)) [ '7b', '22', '6b', '22', '3a', '22', '61', '5c', '75', '32', '30', '32', '63', '7a', '22', '7d' ] >
Note the absence of 202c. In its place is the escaped string "\u202c".
202c
More parameters controlling escaping would be helpful.
The text was updated successfully, but these errors were encountered:
It seems that JSON.stringify() only escapes \u0000-\u001f:
JSON.stringify()
\u0000-\u001f
let i = 0 for (i = 0; i <= 0x9999; i++) { const code = i.toString(16).padStart(4, '0') const str = JSON.parse(`"\\u${code}"`) const encoding = [...JSON.stringify(str)].map(x => x.charCodeAt(0).toString(16)) if (encoding.length > 3) { console.log(code, encoding) } }
I will try testing the change:
- escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, + escapable = /[\\\"\x00-\x1f\u0000-\u001f]/g,
Sorry, something went wrong.
No branches or pull requests
JSONbig.stringify
escapes '\u202c' whileJSON.stringify
does not:Note the absence of
202c
. In its place is the escaped string "\u202c".More parameters controlling escaping would be helpful.
The text was updated successfully, but these errors were encountered: