I am using Newtonsoft.Json.JsonConvert
to serialize Textbox
(WinForms) in json, and I want serialization to skip properties with default values ββor empty arrays.
I'v tried to use NullValueHandling = NullValueHandling.Ignore
in JsonSerializerSettings
, but nothing seems to be affected.
Here is the complete sample code (simplified):
JsonSerializerSettings settings = new JsonSerializerSettings() { Formatting = Formatting.None, DefaultValueHandling = DefaultValueHandling.Ignore, NullValueHandling = NullValueHandling.Ignore, ReferenceLoopHandling = ReferenceLoopHandling.Ignore, ObjectCreationHandling = ObjectCreationHandling.Replace, PreserveReferencesHandling = PreserveReferencesHandling.None, ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor, }; string json = JsonConvert.SerializeObject(textbox, settings);
Any ideas?
source share