Open Dieterbe opened 10 months ago
I added #1385 which is related to this.
What you propose would work for fields of type List<String>
, but not List<String>?
(although I think it's still a good idea for non-nullable lists, to save on serialization time and space).
This could be extended to other "empty types" such as the empty string (for String
-typed fields that are not nullable), and even the integer value 0
(for numerical fields that are not nullable).
Also related: #1340
I have a class like so (simplified/redacted):
I want to transition from my own handwritten toJson(), to a generated one. for the url field i can use the
includeIfNull: false
option, but for the 2nd field, is there a similar option to omit lists if they are empty? i see no such option?Likewise, is it possible to tolerate such a field not being set when decoding json, and setting it to [] on the object?