1
0
mirror of synced 2025-12-17 03:57:28 +08:00

fix escaping bug with backslashes

This commit is contained in:
Zachary Carter
2012-05-27 14:25:28 -07:00
parent f4d68f8fd1
commit 4f24c338fa
2 changed files with 6 additions and 1 deletions

View File

@@ -12,7 +12,7 @@
JSONString JSONString
: STRING : STRING
{$$ = yytext;} {$$ = yytext.replace(/\\\\/g, "\\");}
; ;
JSONNumber JSONNumber

View File

@@ -7,6 +7,11 @@ exports["test object"] = function () {
assert.deepEqual(parser.parse(json), {"foo": "bar"}); assert.deepEqual(parser.parse(json), {"foo": "bar"});
}; };
exports["test escaped backslash"] = function () {
var json = '{"foo": "\\\\"}';
assert.deepEqual(parser.parse(json), {"foo": "\\"});
};
exports["test string with escaped line break"] = function () { exports["test string with escaped line break"] = function () {
var json = '{"foo": "bar\\nbar"}'; var json = '{"foo": "bar\\nbar"}';
assert.deepEqual(parser.parse(json), {"foo": "bar\\nbar"}); assert.deepEqual(parser.parse(json), {"foo": "bar\\nbar"});