I want to mask/hide only json values not keys. For Ex:-
myObject = {"Name":"value1","Phoneno":"545454545445"}
Output should be like below:
myObject = {"key1":"********","key2":"*****"}
Can you please tell me, how we can do this in nodejs? Thanks.
How about:
let myObject = { "Name": "value1", "Phoneno": "545454545445" };
let output = {};
function mask(value: string) {
let maskedValue = "";
for (let i = 0; i < value.length; i++) {
maskedValue += "*";
}
return maskedValue;
}
Object.keys(myObject).forEach(key => {
output[key] = mask(myObject[key]);
});
console.log(output); // Object {Name: "******", Phoneno: "************"}