How to exclude field from toJson serialization?
Hi
Currently JsonKey annotation have ignore parameter, but it's generalized for both fromJson and toJson.
The idea is to have a control over which fields can be serialized via toJson method and then sent over internet.
Could there be implemented additional parameter bool? excludeToJson ?
I'd actually like the above and one step further.. I have a backend SQL database that on Inserts has some Not Null with default database fields. So whilst I'm using this solution, toJson converts to a null value as it should when it's a nullable field, but if it's null on the data side I'd like to exclude the field in the toJson.. So I need the option above for things like the id field that's automatically generated on insert, but also an option to dynamically exclude fields based on their value.
Duplicate of #569
Trying to align all of these requests into one place!
I have a (draft) PR out on this. I'd LOVE (early) feedback about if this works for what folks need here: https://github.com/google/json_serializable.dart/pull/1256
I still need to do some documentation and testing...
@JulianSwales – please open a separate issue for your request!