this is my code, and i can get strings like status, but for example "proxy" i cannot because is inside of "8.8.8.8", my question is, how can I get the value of "proxy" with GSON.
{
"status": "ok",
"8.8.8.8": {
"asn": "AS15169",
"provider": "Google LLC",
"continent": "North America",
"country": "United States",
"isocode": "US",
"latitude": 37.751,
"longitude": -97.822,
"proxy": "no",
"type": "Business"
}
}
public static void main(String[] args) {
URL url = null;
try {
url = new URL("https://proxycheck.io/v2/8.8.8.8?vpn=1&asn=1&tag=proxycheck.io");
URLConnection request = url.openConnection();
request.connect();
JsonParser jp = new JsonParser();
JsonElement root = jp.parse(new InputStreamReader((InputStream) request.getContent()));
System.out.println(root);
JsonObject rootobj = root.getAsJsonObject();
JsonElement proxy = rootobj.get("8.8.8.8");
System.out.println(proxy);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…