forked from ibmruntimes/yieldable-json
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Both APIs fail when the key or value contain vertical tab. Fix that by adding escape sequencing for vertical tab Add two unit tests to validate this scenario. Fixes: ibmruntimes#31
- Loading branch information
Ravali Yatham
authored and
Ravali Yatham
committed
Dec 20, 2021
1 parent
5809572
commit 678a4cf
Showing
3 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters