Open
Description
Hopefully this already has a solution, but i want to request a flag similar to includeIfNull which removes an object where all its fields are null, so given
@freezed
class Transfer with _$Transfer {
@JsonSerializable(explicitToJson: true, includeIfNull: false)
const factory Transfer({
String? provider,
String? comment,
double? amount,
}) = _Transfer;
factory Transfer.fromJson(Map<String, dynamic> json) => _$TransferFromJson(json);
}`
Given the model is nested in a parent
if all fields were null the output would be :
{
"transfer": {}
}
without includeIfNull the output would be :
{
"transfer":{
"provider":null,
"comment":null,
"amount":null
}
}
i am requesting a flag to make the output :
{}
currently i have to make a check that any of these fields are not null before i include the object, so if there is a better way please let me know.
Many thanks
Metadata
Metadata
Assignees
Labels
No labels