readResponseList

Versionshinweise

21.2

Code

Groovy
List<T> RestUtils.readResponseList(Response response, Class<T> type)

Beschreibung

Liest den Antwort-Stream als Liste mit Elementen vom angegebenen Typ.

Parameter

  • response - Die auszulesende Antwort.

  • type - Der Typ der Listenelemente.

Rückgabe

Die Antwort-Liste oder eine leere Liste, falls keine Antwort existiert.

Beispiele

Groovy
// call a service which returns a list of specific types
...
Response response = RestUtils.get(request);
int status = RestUtils.getStatus(response);
if (status != 200)
{
  // do error handling
  return;
}
// read the response of the call
List<Person> responseList = RestUtils.readResponseList(response, Person.class);
...