Prevent serialization if value is null or whitespace in JSON.NET
问题 I have an object that needs to be serialized in such a way that both null and "whitespace" (empty or just spaces) values are not serialized. I don't control the object itself and therefore can't set attributes, but I know that all the properties are strings. Setting NullValueHandling to Ignore obviously only gets me part of the way to the solution. It "seems" (as best I understand) like what I need to do is create a custom DefaultContractResolver but I haven't come up with a solution that