I have this code:
try {
URL url = new URL("My api url");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.addRequestProperty("User-Agent", "MyUserAgent");
InputStream inputStream = connection.getInputStream();
InputStreamReader reader = new InputStreamReader(inputStream);
JsonElement element = new JsonParser().parse(reader);
System.out.println(element);
} catch (IOException e) {
e.printStackTrace();
}
My api response:
[
{
"id": 12345,
"name": "1.0"
}
]
I need to get the name parameter as a string, but I don't know how to do it.
"1.0"