toJSON method

  1. @override
Map<String, dynamic> toJSON()
override

Serializes the model to JSON.

Returns:

  • A map representing the model in JSON format.

Implementation

@override
Map<String, dynamic> toJSON() {
  final json = <String, dynamic>{};
  for (final field in fields) {
    final fieldValue = field.toJSON();
    if (fieldValue != null) {
      json[field.fieldName] = fieldValue;
    }
  }
  return json;
}