You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
theheapdump
changed the title
Urgent | Important | Blocked - big-json createStringifyStream unable to handle blank keys in JSON object
big-json createStringifyStream unable to handle blank keys in JSON object
Aug 12, 2022
PFB the sample programt to reproduce this
const bigJSON = require('big-json');
function tryit() {
const objBlankKeyBlankVal = {'': 'data1', 'key1': ''};
console.log('STRINGIFY OUTPUT ' , JSON.stringify(objBlankKeyBlankVal));
let str = '';
bigJSON.createStringifyStream({body: objBlankKeyBlankVal}).on(
'data', (d) => {
str += d.toString();
console.log("STR = " + str);
});
}
tryit();
PFB the output
STRINGIGY OUTPUT {"":"data1","key1":""}
STR = {
STR = {"data1"
STR = {"data1",
STR = {"data1","key1":
STR = {"data1","key1":""
STR = {"data1","key1":""}
Please notice - the blank key is lost and stringified JSON is malformed
The reverse actually works
Sample Code
function tryit() {
const jsonParseStream = bigJSON.createParseStream();
Stream.Readable.from(JSON.stringify({'': 'data1', 'key1': ''}))
.pipe(jsonParseStream);
jsonParseStream.on('data', (data) => {
console.log('TEST-VALUE : ', data);
});
}
Sample Output
TEST-VALUE : { '': 'data1', key1: '' }
The text was updated successfully, but these errors were encountered: