zaach / jsonlint

A JSON parser and validator with a CLI.
http://zaach.github.com/jsonlint/
1.94k stars 420 forks source link

unicode escaping in strings is not parsed correctly #102

Open vschoettke opened 6 years ago

vschoettke commented 6 years ago

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);