protected <T extends BaseJsonObject> T getResource(String path, Class<T> type) throws IOException {
HttpURLConnection con = open(path);
try {
JSONObject json = JSONObject.fromObject(IOUtils.toString(con.getInputStream(), "UTF-8"));
T resource = (T) json.toBean(type);
resource.json = json;
return resource;
} catch (IOException e) {
InputStream es = con.getErrorStream();
String payload = es!=null ? IOUtils.toString(es) : "(no data)";