Fonctionne
This commit is contained in:
parent
0008be71bd
commit
e1af24097e
1 changed files with 4 additions and 3 deletions
|
|
@ -16,7 +16,7 @@ import java.util.List;
|
||||||
|
|
||||||
public class StreamifyApiClient {
|
public class StreamifyApiClient {
|
||||||
|
|
||||||
private static final String BASE_URL = "http://api-stream.apps.lehub.tf/api"; // à adapter selon ton API
|
private static final String BASE_URL = "http://api-stream.apps.lehub.tf/api";
|
||||||
private final HttpClient httpClient;
|
private final HttpClient httpClient;
|
||||||
private final Gson gson;
|
private final Gson gson;
|
||||||
|
|
||||||
|
|
@ -40,10 +40,11 @@ public class StreamifyApiClient {
|
||||||
// parser l'objet JSON
|
// parser l'objet JSON
|
||||||
JsonObject obj = gson.fromJson(response.body(), JsonObject.class);
|
JsonObject obj = gson.fromJson(response.body(), JsonObject.class);
|
||||||
|
|
||||||
// récupérer le tableau programs
|
// tableau programs
|
||||||
JsonElement programsElement = obj.get("programs");
|
JsonElement programsElement = obj.get("programs");
|
||||||
|
|
||||||
Type listType = new TypeToken<List<Program>>() {}.getType();
|
Type listType = new TypeToken<List<Program>>() {}.getType();
|
||||||
|
// mappage GSON
|
||||||
List<Program> programs = gson.fromJson(programsElement, listType);
|
List<Program> programs = gson.fromJson(programsElement, listType);
|
||||||
|
|
||||||
return programs;
|
return programs;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue