using Newtonsoft.Json.Linq;
using System.Collections.Generic;
public static class Program
public static void Main()
Console.WriteLine("Hello World");
POCO pocoObj = new POCO();
pocoObj.MaskVal2 = "MaskVal2";
pocoObj.Sub = new POCO_Sub{
SubMaskVal2 = "submaskval2",
string payload = JsonConvert.SerializeObject(pocoObj);
Console.WriteLine(payload);
Console.WriteLine("===Expected===");
Console.WriteLine("===Masked===");
string santizedPayload = MaskFullPayload(payload, new List<string>(){"MaskVal2", "SubMaskVal2", "SubMaskVal3"}, 'X');
Console.WriteLine(santizedPayload);
public static string Mask(this string value, char maskChar)
if(string.IsNullOrEmpty(value))
return new string(maskChar, value.Length);
public static string MaskFullPayload(string payload, List<string> keys, char maskChar){
public static string ExpectedOutput(){
POCO pocoSan = new POCO();
pocoSan.MaskVal2 = "xxxxxxxx";
pocoSan.Sub = new POCO_Sub{
SubMaskVal2 = "xxxxxxxxxxx",
string payload = JsonConvert.SerializeObject(pocoSan);
Console.WriteLine(payload);
public string Val1{get;set;}
public string MaskVal2{get;set;}
public POCO_Sub Sub {get;set;}
public string SubVal1{get;set;}
public string SubMaskVal2{get;set;}
public int SubMaskVal3{get;set;}