toJson method

String toJson()

Serialize object to JSON string

@return

Implementation

String toJson() {
  final val = <String, dynamic>{};

  void writeNotNull(String key, dynamic value) {
    if (value != null) {
      val[key] = value;
    }
  }

  writeNotNull('success', success);
  writeNotNull('message', message);
  writeNotNull('action', action);
  writeNotNull('data', data);
  writeNotNull('errors', errors);

  return Helpers.objectToJson(val);
}