public TextArea textArea;
private Stage stage;
private Scene scene;
private Parent root;
@FXML
public void displayTeamsData() throws Exception {
//Calling the NBA API for teams.
URL urlTeams = new URL("https://www.balldontlie.io/api/v1/teams");
Scanner JsonScan1 = new Scanner(urlTeams.openStream());
//Using the data from the Json scans and putting them into a String called rawData.
StringBuilder rawDataTeams = new StringBuilder();
while (JsonScan1.hasNextLine()) {
rawDataTeams.append(JsonScan1.nextLine());
}
//Creating a gson object
Gson gson = new Gson();
TeamsList teamsList = gson.fromJson(rawDataTeams.toString(), TeamsList.class);
//Accessing team data from TeamsList object
Teams[] teams = teamsList.getData();
//Print details for all teams
if (teams != null) {
for (Teams team : teams) {
System.out.println(team.toString());
}
}
}
The way the api im calling is formatted is like this
TeamAtlanta Hawks
Team ID: 1
Abbreviation: ATL
City: Atlanta
Conference: East
Division: Southeast
Name: Hawks
I just want to display that in the text area how do I do that