Skip to content

Critical | Unable to handle blank keys in JSON object #28

Description

@theheapdump

Please find below the sample JSON object with an empty key

{'': 'data1', 'key1': ''}

function replacer(key, value) {
if (!key) {
console.log('YES' , key, value);
}
return value;
}

let str = '';
const JsonStreamStringify = require('json-stream-stringify');
const stream = new JsonStreamStringify({'': 'data1', 'key1': ''}, replacer , 0, false);
stream.on('data', (data) => {
str += data.toString();
});
stream.on('end', function () {
console.log('PARSING NOW ' , str);
});

On the end event, the output is
// PARSING NOW {"data1","key1":""}

Please note the JSON is malformed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions