Json Masking
Replace fields in json, replacing by something, don't care if property is in depth objects. Very useful to replace passwords, credit card number, etc.
This library matching insensitive values with field namespaces. You can use wildcard * to allow any char in pattern;
Sample
var example = new
{
SomeValue = "Demo",
Password = "SomePasswordHere",
DepthObject = new
{
Password = "SomePasswordHere2",
Card = new
{
Number = "555500022223333"
}
},
CreditCardNumber = "5555000011112222",
Card = new
{
Number = "555500022223333"
}
};
var exampleAsString = JsonConvert.Serialize(example); // value must be a json string to masked
// note that password is only replaced when is in root path
var blacklist = new string[] { "password", "card.number", "*.card.number" "creditcardnumber" };
var mask = "******";
var maskedExampleAsString = exampleAsString.MaskFields(blacklist, mask);
Console.WriteLine(maskedExampleAsString);
Output
{
"SomeValue" : "Demo",
"Password" : "******",
"DepthObject" : {
"Password" : "SomePasswordHere2",
"Card" : {
"Number" : "******"
}
},
"CreditCardNumber" : "******",
"Card" : {
"Number" : "******"
}
}
Install via NuGet
PM> Install-Package JsonMasking
How can I contribute?
Please, refer to CONTRIBUTING
Found something strange or need a new feature?
Open a new Issue following our issue template ISSUE_TEMPLATE
Changelog
See in nuget version history
Did you like it? Please, make a donate :)
if you liked this project, please make a contribution and help to keep this and other initiatives, send me some Satochis.
BTC Wallet: 1G535x1rYdMo9CNdTGK3eG6XJddBHdaqfX