/* Tider for solopgang/nedgang i Sønderborg i json format.

Ønskes data for hele året 2024 fås de her:

https://api.sunrisesunset.io/json?lat=54.918303&lng=9.820069&date_start=2024-01-01&date_end=2024-12-31&time_format=24

For indeværende døgn fås en json string i 24 timers format via: 
 
https://api.sunrisesunset.io/json?lat=54.918303&lng=9.820069&time_format=24

Eksempel på json string for indeværende døgn:

{
  "results": {
    "date": "2024-10-19",
    "sunrise": "07:59:27",
    "sunset": "18:14:06",
    "first_light": "05:58:43",
    "last_light": "20:14:50",
    "dawn": "07:22:33",
    "dusk": "18:51:00",
    "solar_noon": "13:06:47",
    "golden_hour": "17:22:48",
    "day_length": "10:14:38",
    "timezone": "Europe/Copenhagen",
    "utc_offset": 120
  },
  "status": "OK"
}

Arduino kode genereret via ( med json strengen som input):

https://arduinojson.org/v7/assistant/#/step1
*/

// Stream& input;

JsonDocument doc;

DeserializationError error = deserializeJson(doc, input);

if (error) {
  Serial.print("deserializeJson() failed: ");
  Serial.println(error.c_str());
  return;
}

JsonObject results = doc["results"];
const char* results_date = results["date"]; // "2024-10-19"
const char* results_sunrise = results["sunrise"]; // "7:59:27 AM"
const char* results_sunset = results["sunset"]; // "6:14:06 PM"
const char* results_first_light = results["first_light"]; // "5:58:43 AM"
const char* results_last_light = results["last_light"]; // "8:14:50 PM"
const char* results_dawn = results["dawn"]; // "7:22:33 AM"
const char* results_dusk = results["dusk"]; // "6:51:00 PM"
const char* results_solar_noon = results["solar_noon"]; // "1:06:47 PM"
const char* results_golden_hour = results["golden_hour"]; // "5:22:48 PM"
const char* results_day_length = results["day_length"]; // "10:14:38"
const char* results_timezone = results["timezone"]; // "Europe/Copenhagen"
int results_utc_offset = results["utc_offset"]; // 120

const char* status = doc["status"]; // "OK"
