Created
February 20, 2015 18:10
-
-
Save torjusb/9f1cc2e6e5cc9b477118 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"io/ioutil" | |
"net/http" | |
) | |
type StopVisits struct { | |
MonitoredStopVisit map[int]MonitoredStopVisit | |
} | |
type MonitoredStopVisit struct { | |
MonitoringRef string | |
RecordedAtTime string | |
MonitoredVehicleJourney MonitoredVehicleJourney | |
} | |
type MonitoredVehicleJourney struct { | |
MonitoredCall MonitoredCall | |
} | |
type MonitoredCall struct { | |
AimedArrivalTime string | |
AimedDepartureTime string | |
ExpectedArrivalTime string | |
ExpectedDepartureTime string | |
VehicleAtStop bool | |
} | |
func main() { | |
resp, _ := http.Get("http://reisapi.ruter.no/stopvisit/getdepartures/3011484") | |
defer resp.Body.Close() | |
body, _ := ioutil.ReadAll(resp.Body) | |
stops := make([]MonitoredStopVisit, 0) | |
json.Unmarshal(body, &stops) | |
fmt.Printf("%#v", stops[0].MonitoredVehicleJourney.MonitoredCall.ExpectedArrivalTime) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Probably none. There is some information on it here: http://stackoverflow.com/questions/25543520/golang-declare-slice-or-make-slice
So I guess
var stops [] MonitoredStopVisit
would be preferable, as it doesn't allocate any memory until it actually gets data? But I guess in reality, it doesn't really matter (at least in this case) as it will always be populated with data?