How to have System.Text.Json skip properties of types that are not serializable? #97473
Unanswered
WenningQiu
asked this question in
General
Replies: 1 comment
-
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am running into an exception when serializing objects with a property of type
Func<string>
. SinceFunc<string>
is code, it does not make any sense for it to be serialized at all.I was expecting such properties to be automatically excluded by
System.Text.Json.JsonSerializer
, but apparentlySystem.Text.Json.JsonSerializer
pressed ahead and ran into an exception:So my questions:
System.Text.Json.JsonSerializer
be designed to skip properties of types that are not serializable?System.Text.Json.JsonSerializer
currently does not skip such properties, what is the best way to customizeSystem.Text.Json.JsonSerializer
to do that? (I know slapping[JsonIgnore]
attribute on the property will help, but I don't want to do it manually on individual properties.Beta Was this translation helpful? Give feedback.
All reactions