❔ How to serialize certain null values with System.Text.Json
In System.Text.Json, if I have something like
I can serialize a list of items but ignore null values when writing, but what should I do if I want to serialize a single
null
value and ignore all others, something like this:
4 Replies
I misread your question 🤦
Always
and Never
wouldnt work since I only want to write it in some conditions (Text
matches x value or some other condition)
WhenWritingDefault
would ignore all null values
and WhenWritingNull
wouldnt let me write nullYou need a custom converter
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.