0

my question is regarding an API, and how I can extract an JSONArray from it. In specifics, I want an Array of the country names. the screenshot is at the very beginning of the API and has Afghanistan as the first country (sorted in alphabetical order). I know I could get an Array of info for each country if I did something like:

        URL url = new URL("https://pomber.github.io/covid19/timeseries.json");
        BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
        
        JSONParser jsonParser = new JSONParser();
        JSONObject myObject = (JSONObject) jsonParser.parse(br);
        
        JSONArray countryArray = (JSONArray) myObject.get("Afghanistan");

Through using the country name as a key, but the country names themselves don't have keys.

I'd appreciate any help I could get.

An additional Screenshot is attached to show how a country's array of info end and how another begins.

Text

Text

0 Answers0