From fe0df473044f3e0871043d5d052e57f062bebe74 Mon Sep 17 00:00:00 2001 From: Peder Vatn Austad Date: Mon, 20 May 2024 20:00:39 +0200 Subject: [PATCH] 0.1.6 added the json part of Recorded calls :P --- main.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/main.go b/main.go index b0b6a5b..cb4c45c 100644 --- a/main.go +++ b/main.go @@ -330,6 +330,33 @@ func printData(data *Data) { if call.ExpectedDepartureTime != "" { fmt.Println("RecordedCall ExpectedDepartureTime:", call.ExpectedDepartureTime) } + + jsonObjectRC := make(map[string]interface{}) + + if call.StopPointName != "" { + jsonObjectRC["StopPointName"] = call.StopPointName + } + if call.ArrivalPlatformName != "" { + jsonObjectRC["ArrivalPlatformName"] = call.ArrivalPlatformName + } + if call.DeparturePlatformName != "" { + jsonObjectRC["DeparturePlatformName"] = call.DeparturePlatformName + } + if call.PredictionInaccurate != "" { + jsonObjectRC["PredictionInaccurate"] = call.PredictionInaccurate + } + if call.Occupancy != "" { + jsonObjectRC["Occupancy"] = call.Occupancy + } + + // Convert the JSON object to a JSON string + jsonString, err := json.Marshal(jsonObjectRC) + if err != nil { + log.Fatal(err) + } + + // Print the JSON string for the current journey + fmt.Println(string(jsonString)) } } for _, estimatedCall := range journey.EstimatedCalls {