From 495d088f566252210768d8481f66e9f032befb76 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Thu, 4 Jul 2024 14:36:16 +0200 Subject: [PATCH] Fix encondig for Airline struct --- .../acmesky/tm_search_flight_on_airline.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/internal/handlers/acmesky/tm_search_flight_on_airline.go b/internal/handlers/acmesky/tm_search_flight_on_airline.go index 041e416..ea8a53b 100644 --- a/internal/handlers/acmesky/tm_search_flight_on_airline.go +++ b/internal/handlers/acmesky/tm_search_flight_on_airline.go @@ -2,6 +2,7 @@ package handlers import ( "context" + "encoding/json" "fmt" "github.com/charmbracelet/log" @@ -30,7 +31,20 @@ func TMSearchFlightsOnAirline(client worker.JobClient, job entities.Job) { airlines := variables["airlines"].([]interface{}) index := int(variables["loopCounter"].(float64)) - 1 - airline := airlines[index].(models.Airline) + + m := airlines[index] + jsonData, err := json.Marshal(m) + if err != nil { + fmt.Println("Error marshaling map to JSON:", err) + return + } + + var airline models.Airline + err = json.Unmarshal(jsonData, &airline) + if err != nil { + fmt.Println("Error unmarshaling JSON to struct:", err) + return + } interests := variables["interests"].([]interface{})