I currently use Newtonsoft and have my own ContractResolver that inherits from the DefaultContractResolver. My class overrides the CreateProperties method and when a type is passed to that method I call base.CreateProperties() which returns a List<JsonProperty> and I then add new properties to the list so that when it is serialized I have the extra properties eg.
public class Person
{
public string Name {get;set;}
}
I have the README about json formatters and resolvers but I don't quite see how I can manipulate every object that is passed to the serializer, for example the formatters are based on type eg IJsonFormatter<T> but I'm not sure if implementing that as public class MyFormatter : IJsonFormatter<object> would be the correct way to go?
Could you offer some advice on how to manipulate the object before it's serialized?
Hi,
I currently use Newtonsoft and have my own ContractResolver that inherits from the
DefaultContractResolver
. My class overrides theCreateProperties
method and when a type is passed to that method I callbase.CreateProperties()
which returns aList<JsonProperty>
and I then add new properties to the list so that when it is serialized I have the extra properties eg.I have the README about json formatters and resolvers but I don't quite see how I can manipulate every object that is passed to the serializer, for example the formatters are based on type eg
IJsonFormatter<T>
but I'm not sure if implementing that aspublic class MyFormatter : IJsonFormatter<object>
would be the correct way to go?Could you offer some advice on how to manipulate the object before it's serialized?
Thanks