TRObject'de JSON formatta olan veriyi nasil parse edebiliriz ? Ornegin asagidaki gibi bir veriden sadece belirli elemanlari cekmek isterim. {"location":{"name":"Konya","region":"Konya","country":"Turkey","lat":37.8656,"lon":32.4825,"tz_id":"Europe/Istanbul","localtime_epoch":1750169564,"localtime":"2025-06-17 17:12"},"current":{"last_updated_epoch":1750168800,"last_updated":"2025-06-17 17:00","temp_c":25.4,"temp_f":77.7,"is_day":1,"condition":{"text":"Sunny","icon":"//cdn.weatherapi.com/weather/64x64/day/113.png","code":1000},"wind_mph":14.1,"wind_kph":22.7,"wind_degree":2,"wind_dir":"N","pressure_mb":1017.0,"pressure_in":30.03,"precip_mm":0.0,"precip_in":0.0,"humidity":19,"cloud":25,"feelslike_c":24.3,"feelslike_f":75.8,"windchill_c":23.7,"windchill_f":74.6,"heatindex_c":23.3,"heatindex_f":73.9,"dewpoint_c":1.1,"dewpoint_f":34.1,"vis_km":10.0,"vis_miles":6.0,"uv":2.8,"gust_mph":16.2,"gust_kph":26.1}} Python icin bu yontemi uygulyabilirdik : data = {"location":{"name":"Konya","region":"Konya","country":"Turkey","lat":37.8656,"lon":32.4825,"tz_id":"Europe/Istanbul","localtime_epoch":1750169564,"localtime":"2025-06-17 17:12"},"current":{"last_updated_epoch":1750168800,"last_updated":"2025-06-17 17:00","temp_c":25.4,"temp_f":77.7,"is_day":1,"condition":{"text":"Sunny","icon":"//cdn.weatherapi.com/weather/64x64/day/113.png","code":1000},"wind_mph":14.1,"wind_kph":22.7,"wind_degree":2,"wind_dir":"N","pressure_mb":1017.0,"pressure_in":30.03,"precip_mm":0.0,"precip_in":0.0,"humidity":19,"cloud":25,"feelslike_c":24.3,"feelslike_f":75.8,"windchill_c":23.7,"windchill_f":74.6,"heatindex_c":23.3,"heatindex_f":73.9,"dewpoint_c":1.1,"dewpoint_f":34.1,"vis_km":10.0,"vis_miles":6.0,"uv":2.8,"gust_mph":16.2,"gust_kph":26.1}} city = data["location"]["name"]
country = data["location"]["country"]
temp = data["current"]["temp_c"]
weather_desc = data["current"]["condition"]["text"]
humidity = data["current"]["humidity"]
Ama ayni islem TRObject'de nasil yapilir ?
|