KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I want to set a contract serializer just for certain types in my ASP.NET Web API application. I can set the settings globally in the App_Start/FormatterConfig.cs like this: public static void RegisterGlobalFormatters(MediaTypeFormatterCollection formatters) { jsonSerializerSettings.ContractResolver = new CriteriaContractResolver(new List<string>(new string[]{"mdData", "name", "label"})); ... but how can I just apply this to one or more specific class types? The reason I want to do this is because I need to be able to set what fields should be serialized at runtime based on configuration or parameters to the web service similar to these examples: Using JSON.net, how do I prevent serializing properties of a derived class, when used in a base class context? http://json.codeplex.com/discussions/347610
Tags (comma-separated)
Save Edits
Cancel