diff --git a/src/main/java/RestAPISchnittstelle/RestApiClient.java b/src/main/java/RestAPISchnittstelle/RestApiClient.java index 8fa5486..7f28ca7 100644 --- a/src/main/java/RestAPISchnittstelle/RestApiClient.java +++ b/src/main/java/RestAPISchnittstelle/RestApiClient.java @@ -5,6 +5,10 @@ import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.nio.charset.StandardCharsets; +import java.nio.file.WatchEvent; + +import Logik.Kind; +import com.google.gson.Gson; /** * noch nicht getestet @@ -25,7 +29,7 @@ public class RestApiClient implements IRestAPI{ public static void main(String[] args){ - new RestApiClient().get("Kind", 2); + new RestApiClient().get("Kind", 1); } @@ -45,9 +49,12 @@ public class RestApiClient implements IRestAPI{ // Send the request and get the response HttpResponse httpResponse = client.send(httpRequest, HttpResponse.BodyHandlers.ofString()); + Gson gson = new Gson(); + Kind test = gson.fromJson(httpResponse.body(), Kind.class); + // Print the response status code and body System.out.println("Status Code: " + httpResponse.statusCode()); - System.out.println("Response Body: " + httpResponse.body()); + System.out.println("Response Body: " + test.getName()); } catch (Exception e) { e.printStackTrace(); } diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index 336a917..a308e0e 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -2,6 +2,7 @@ module de.subway_surfers.vpr_app { requires javafx.controls; requires javafx.fxml; requires java.net.http; + requires com.google.gson; opens de.subway_surfers.vpr_app to javafx.fxml;