toJson method

Map<String, dynamic> toJson()

Converts the ResponseListDTO to a JSON object.

This method can be used when making HTTP requests to convert the response list to a format that can be sent in the request.

Implementation

Map<String, dynamic> toJson() {
  Map<String, dynamic> data = <String, dynamic>{};
  data["message"] = message;
  data["status"] = status;

  if (items.isNotEmpty) {
    data["items"] = items.map((e) => e.toJson()).toList();
  }
  if (hasError) {
    data["hasError"] = hasError;
    data["error"] = error;
  }

  return data;
}