Open theheapdump opened 2 years ago
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: '' }
repro.txt
https://github.com/Faleij/json-stream-stringify/issues/28
In the latest release I picked up ^3.0.0 of json-stream-stringify. Let me know if that addresses this issue.
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: '' }