google / google/built_value.dart
Extend field serialization options
- Dominant language
- Dart
- Stars
- 886
- Forks
- 195
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 4
Description
It often happens that I need extended serialization options for fields (even though I can use custom serializers, but that kinda mitigates some generation profit).
1. don't strip a field if it's null while ~~de~~serializing; dup of #1049
1. strip a field while serializing.
Something like:
```
@BuiltValueField(stripIfNull: false, stripForSerialize: true)
```
For now I think there are couple solutions beside fully custom serializers:
1. Use postprocessing (extensions/helper classes) to add/remove certain fields after/before serialization.
2. Write a class that stores single value and add a serializer for it. Something like `UnstripableNullField` and `StipableField` and add serializers implementing specific logic for it. Maybe `ExtendedField(this.value, this.stripIfNull, this.stripForSerialize);` is better.
But all of them requires some boilerplate while it could be eliminated with this options.
Contributor guide
Assessment
This issue has not been assessed yet.