jsonlint icon indicating copy to clipboard operation
jsonlint copied to clipboard

unicode escaping in strings is not parsed correctly

Open vschoettke opened this issue 7 years ago • 0 comments

Jsonlint does not parse strings with unicode escape characters correctly. Instead of parsing the unicode \uXXXX it's escaping it, so the resulting string is wrong.

e.g.: parsing '{\n"name": "\\u30d0\\u30b0"\n}\n' results in { name: '\\u30d0\\u30b0' } but should be { name: '\u30d0\u30b0' }

Here is the code to reproduce the error:

var jsonlint = require("jsonlint");
var test = '{"name": "\\u30d0\\u30b0"}';
var jsonlintRes = jsonlint.parse(test);
var jsonparseRes = JSON.parse(test);
console.log("PARSE SAME?", jsonlintRes === jsonparseRes);
console.log("jsonlint result:", jsonlintRes);
console.log("JSON.parse result:", jsonparseRes);

vschoettke avatar Nov 27 '17 12:11 vschoettke