try{
// create a client and then a web resource
Client client = Client.create();
WebResource webResource = client.resource(JSonURL);
// create a response object with the specified accepted Media-Type
ClientResponse clientResponse = webResource.accept("application/json").get(ClientResponse.class);
if (clientResponse.getStatus() != 200){
throw new RuntimeException("Failed to fetch data :: HTTP request status: "+ clientResponse.getStatus());
}
// retrieve the json data
String jsonData = clientResponse.getEntity(String.class);