Can I optionally turn off the JsonIgnore attribute at runtime?

asked10 years ago
last updated10 years ago
viewed15.5k times
Up Vote33Down Vote

I am creating a JSON file with Newtonsoft.Json from a set of classes. The file created is very large, so I have created JsonProperty's for the properties to reduce the size and added JsonIgnore and custom formatting for some datatypes.

The result is a reduction from 24MB to 1MB, which is great; however, I'd like the option to produce either the full version or the reduced property version at runtime.

Is there anyway I can get the serializer to optionally use the attributes?