0

Einbindung api.weatherapi.com

Hallo liebe Ninoxer,

ich binde aktuell Wetterdaten von api.weatherapi.com eines definierten Datums in Ninox ein.
Das klappt soweit sehr gut. Allerdings kann ich nicht auf alle Werte des JSON zugreifen, da diese durch geschützte Bezeichnung (z.B. date oder day) in Ninox reserviert sind und als Nxcode "erkannt" werden.

let url_history := "https://api.weatherapi.com/v1/history.json?q=09116%20Chemnitz&dt=" + datum +
    "&hour=" +
    stunde +
    "&lang=de&key=" +
    apikey;
let response := http("GET", url_history);
let jsonresponse := formatJSON(response.result);

Hier ein Beispiel des JSON.

Auf den Wert forecast.forecastday.day.avgtemp_c kann ich leider nicht zugreifen, da Ninox "day" als Code erkennt. Gibt es noch einen anderen Weg, um auf die Werte zuzugreifen?

{"location":{"name":"Chemnitz","region":"Sachsen","country":"Germany","lat":50.8333,"lon":12.9167,"tz_id":"Europe/Berlin","localtime_epoch":1750751170,"localtime":"2025-06-24 09:46"},"forecast":{"forecastday":[{"date":"2025-01-01","date_epoch":1735689600,"day":{"maxtemp_c":7.4,"maxtemp_f":45.3,"mintemp_c":1.2,"mintemp_f":34.1,"avgtemp_c":4.6,"avgtemp_f":40.3,"maxwind_mph":26.6,"maxwind_kph":42.8,"totalprecip_mm":0,"totalprecip_in":0,"totalsnow_cm":0,"avgvis_km":10,"avgvis_miles":6,"avghumidity":57,"daily_will_it_rain":0,"daily_chance_of_rain":0,"daily_will_it_snow":0,"daily_chance_of_snow":0,"condition":{"text":"bedeckt","icon":"//cdn.weatherapi.com/weather/64x64/day/122.png","code":1009},"uv":2},"astro":{"sunrise":"08:11 AM","sunset":"04:13 PM","moonrise":"09:50 AM","moonset":"05:38 PM","moon_phase":"Waxing Crescent","moon_illumination":1},"hour":[{"time_epoch":1735729200,"time":"2025-01-01 12:00","temp_c":6,"temp_f":42.9,"is_day":1,"condition":{"text":"bedeckt","icon":"//cdn.weatherapi.com/weather/64x64/day/122.png","code":1009},"wind_mph":22.4,"wind_kph":36,"wind_degree":226,"wind_dir":"SW","pressure_mb":1019,"pressure_in":30.08,"precip_mm":0,"precip_in":0,"snow_cm":0,"humidity":51,"cloud":100,"feelslike_c":1,"feelslike_f":33.7,"windchill_c":1,"windchill_f":33.7,"heatindex_c":6,"heatindex_f":42.9,"dewpoint_c":-3.2,"dewpoint_f":26.3,"will_it_rain":0,"chance_of_rain":0,"will_it_snow":0,"chance_of_snow":0,"vis_km":10,"vis_miles":6,"gust_mph":32.2,"gust_kph":51.8,"uv":2}]}]}}

Vielen lieben Dank vorab. 

2 Antworten

null
    • Gotje_Ing
    • vor 12 Tagen
    • Gemeldet - anzeigen

    Moin,

    das Problem sind nicht die Ninox-Funktionen, sondern das Array im forcastday. So funktionierts:
    JSON.forecast.first(forecastday).day.avgtemp_c

    oder halt iterativ:
    for foreCastDay in JSON.forecast.forecastday do
        foreCastDay.day.avgtemp_c
    end

    Je nach gewünschtem Output.

      • Henrik_Striegler.1
      • vor 12 Tagen
      • Gemeldet - anzeigen

       

      vielen Dank. Klappt hervorragend. Das war der entscheidende Hinweis😀

Content aside

  • Status Answered
  • vor 12 TagenZuletzt aktiv
  • 2Antworten
  • 18Ansichten
  • 2 Folge bereits