I have an object which has several collection properties defined with public getter but private setter, In this case JsonConvert.PopulateObject
adds the deserialized items to these collections leaving the existing items untouched.
I need a behavior when such member collections get cleared before deserialization.
I tried to manually clear the collections in a method marked with the [OnDeserializing]
attribute.
The problem with that approach is that it will still clear the collections even if the collection property does not exist in the JSON string.
I need a way when only those collections get cleared which are actually defined in the JSON string. Those which are undefined should be kept untouched.
Thanks