If I'd like to retrieve the JSON data from this github link: https://github.com/EthanRBrown/rrad/blob/master/addresses-us-100.json and store it into a JSONObject, is that possible? Is there another way for me to achieve this?
I'm using org.json.simple.JSONObject
CodePudding user response:
Yes it is possible.
You might want to access raw link instead of browser friendly one - https://raw.githubusercontent.com/EthanRBrown/rrad/master/addresses-us-100.json
Then you download that for example with HttpClient and then convert String into JSONObject.
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpGet request = new HttpGet(address);
CloseableHttpResponse response = httpClient.execute(request);
HttpEntity entity = response.getEntity();
String result = EntityUtils.toString(entity);
/* now convert String result to JSONObject */