Good day!
I am currently using the Newtonsoft Json Serializer through the following code:
private string serializeAndIgnoreEmail(UserMembership obj)
{
var json = JsonConvert.SerializeObject(obj, Formatting.Indented,
new JsonSerializerSettings() { ContractResolver = new DocumentIdContractResolver() });
return json;
}
private class DocumentIdContractResolver : CamelCasePropertyNamesContractResolver
{
protected override List<MemberInfo> GetSerializableMembers(Type objectType)
{
return base.GetSerializableMembers(objectType).Where(o => o.Name != "Email").ToList();
}
}
Everytime I need to serialize an object I call the 'serializeAndIgnoreEmail' method. I now want to replace the content of each property with it's encrypted version and I don't know where to do this.
My guess would be to override a method in the 'DocumentIdContractResolver', but there are so many CreateBlahBlahBlah ones, that I find it very hard to work with them.
Is this the right approach, to continue modifying the ContractResolver or should I try something else?
Thank you!