GSON Test
This commit is contained in:
parent
db26bca5a3
commit
bf9c99672d
@ -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<String> 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();
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user