So I'm at lost how to do this: the goal is simply to make a call to the openweather api in java and have the result be returned on the console. I can't find any tutorials on how to do this, only on how to parse JSON data from another file...
Erm is this going in the right direction? No idea. Modified as per suggestion to attempt to use Gson
import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import javax.json.Json;
import javax.json.JsonArray;
import javax.json.JsonObject;
import javax.json.JsonReader;
import javax.json.JsonValue;
public class ApiJSONRead {
URL apiURL = new URL("http://api.openweathermap.org/data/2.5/find?q=London&APPID=(idhere)");
public static void main(String[] args) throws IOException {
JsonObject jobj = new Gson().fromJson(apiURL, JsonObject.class);
var Jsonresponse = jobj.get("weather").getAsString();
System.out.println(Jsonresponse);
}
}