-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindego.go
29 lines (23 loc) · 896 Bytes
/
indego.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package main
import (
"fmt"
"net/http"
"io/ioutil"
"encoding/json"
)
func main() {
// Set URL of the Philadelphia Indego Bike Share API, along with a user-agent to use for the HTTP request
url := "https://www.rideindego.com/stations/json/"
user_agent := "Indego Go API Library - https://github.com/ericoc/indego-go-lib"
// Perform the HTTP request and get the resulting JSON
req, _ := http.NewRequest("GET", url, nil)
req.Header.Set("User-Agent", user_agent)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
// Do something that I do not understand at all with the JSON
var result map[string]interface{}
json.Unmarshal([]byte(body), &result)
// Print whatever output I got from the stuff above that I don't quite understand
fmt.Printf("Result: %s", result["features"])
}