Open Pvlerick opened 5 years ago
If you don't want to use [IgnoreDataMember]
to completely ignore the member,
you can probably use the ShouldSerializePattern for that: https://github.com/neuecc/Utf8Json#shouldserializexxx-pattern
And in the ShouldSerializeValue method check if it throws an exception and return true/false appropriately.
Well, the idea is not to have to mess with the objects that I want to serialize.
It's a bit of a deviated use of this library, but I'd like to use with NLog for structured logging, and in this case I don't know in advance which are the object that are going to be serialized.
Is there any way to customize the behaviour of the serializer so that this doesn't throw? For example, e.Message could be set as the value for that property.