Skip to content

Commit

Permalink
Fix encondig for Airline struct
Browse files Browse the repository at this point in the history
  • Loading branch information
boozec committed Jul 4, 2024
1 parent f718be6 commit 495d088
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion internal/handlers/acmesky/tm_search_flight_on_airline.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package handlers

import (
"context"
"encoding/json"
"fmt"

"github.com/charmbracelet/log"
Expand Down Expand Up @@ -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{})

Expand Down

0 comments on commit 495d088

Please sign in to comment.