Ответ - {"message": "точный", "cod": "200", "count": 1, "list": [{"id": 2643743, "name": "London", "ord ": {" lat ": 51.5085," lon ": -0.1258}," main ": {" temp ": 7," давление ": 1012," влажность ": 81," temp_min ": 5," temp_max ": 8},
Мне нужно напечатать значение temp.and я сделал следующее:
CloseableHttpResponse response = restClient.get(url);
//2. JsonString:
String responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
JSONObject responseJson = new JSONObject(responseString);
System.out.println("The response from API is:"+ responseJson);
System.out.println("-------------------------------------");
String[] array = responseString.split(",");
for (String i: array)
{
if (i.startsWith("main:"))
{
//System.out.println(i.substring(3));
}
}
JSONArray jsonArray=responseJson.getJSONArray("list");
for(int i=0; i<jsonArray.length();i++){
JSONObject jso = jsonArray.getJSONObject(i);
System.out.println(jso.getString("temp"));