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.
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.