Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

big-json createStringifyStream unable to handle blank keys in JSON object #25

Open
theheapdump opened this issue Aug 12, 2022 · 3 comments

Comments

@theheapdump
Copy link

theheapdump commented 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: '' }

@theheapdump
Copy link
Author

repro.txt

@theheapdump 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
@theheapdump
Copy link
Author

@DonutEspresso
Copy link
Owner

In the latest release I picked up ^3.0.0 of json-stream-stringify. Let me know if that addresses this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants