diff --git a/test/test-parse-verticaltab.js b/test/test-parse-verticaltab.js new file mode 100644 index 0000000..76322b3 --- /dev/null +++ b/test/test-parse-verticaltab.js @@ -0,0 +1,22 @@ +'use strict'; + +const yj = require('../index'); +const tap = require('tap'); + +//string with nested quotes +const str = '{"name":"Ila Gould","age":22,"gender":"female","nested":"\\u000bcheck"}'; + +yj.parseAsync(str, (error, obj) => { + if (!error){ + tap.equal(str,JSON.stringify(obj)); + yj.stringifyAsync(obj,(err,data) => { + if(!err){ + tap.equal(data,str); + } + else + tap.fail(err); + }) + } + else + tap.fail(error); +}); diff --git a/test/test-stringify-verticaltab.js b/test/test-stringify-verticaltab.js new file mode 100644 index 0000000..c43e2bb --- /dev/null +++ b/test/test-stringify-verticaltab.js @@ -0,0 +1,27 @@ +'use strict'; + +const yj = require('../index'); +const tap = require('tap'); + +//Object with nested quotes +const obj = { + name: 'Jacqueline Poole', + gender: 'female', + age: 40, + a:"\vb" +}; + +yj.stringifyAsync(obj, (err, str) => { + if (!err){ + tap.equal(JSON.stringify(obj), str); + yj.parseAsync(str,(error,data) => { + if(!error){ + tap.same(data,obj); + } + else + tap.fail(error); +}) + } + else + tap.fail(err); +}); diff --git a/yieldable-stringify.js b/yieldable-stringify.js index b3814f6..56a4faa 100755 --- a/yieldable-stringify.js +++ b/yieldable-stringify.js @@ -47,6 +47,7 @@ let normalize = (string, flagN) => { '\n': '\\n', '\f': '\\f', '\r': '\\r', + '\v': '\\u000b', '"': '\\"', }; // Escape is implemented globally