json-string-redactor
v1.0.1
Published
Redacts JSON string values for specified keys
Downloads
2
Readme
json-string-redactor
Redacts JSON string values for specified keys
npm i json-string-redactor
Example
const jsonRedactor = require('json-string-redactor');
const input = JSON.stringify({
name: 'Test0',
prop0: 'I should not be redacted',
child: {
name: 'Test1',
prop1: 'I should not be redacted either',
child: {
name: 'Test2',
child: {
name: 'Test3',
secret: 'This is a secret',
},
},
},
});
const redacted = jsonRedactor(['name', 'secret'], input);
/*
redacted is now:
{
"name": "*****",
"prop0": "I should not be redacted",
"child": {
"name": "*****",
"prop1": "I should not be redacted either",
"child": {
"name": "*****",
"child": {
"name": "*****",
"secret": "****************"
}
}
}
}
*/
Note: You get 1 *
per character redacted :)