Last active
August 29, 2015 14:24
-
-
Save eko/8b3cb709d622e3e86734 to your computer and use it in GitHub Desktop.
RATP Information trafic
This file contains 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" | |
"io/ioutil" | |
"net/http" | |
"fmt" | |
) | |
type RatpLine struct { | |
Name string `json:"name"` | |
Icon string `json:"icon"` | |
Level int `json:"level"` | |
Title string `json:"title"` | |
Message string `json:"message"` | |
Url string `json:"url"` | |
} | |
type RatpTransport struct { | |
Name string `json:"name"` | |
Icon string `json:"icon"` | |
Url string `json:"url"` | |
Lines map[string]RatpLine `json:"lines"` | |
} | |
type RatpStatus struct { | |
Rer RatpTransport `json:"rer"` | |
Metro RatpTransport `json:"metro"` | |
Tram RatpTransport `json:"tram"` | |
} | |
type RatpApi struct { | |
Now string `json:"now"` | |
Unavailable string `json:"unavailable"` | |
Status RatpStatus `json:"status"` | |
} | |
func main() { | |
res, err := http.Get("http://www.ratp.fr/meteo/ajax/data") | |
if err != nil { panic(err) } | |
body, err := ioutil.ReadAll(res.Body) | |
data := RatpApi{} | |
err = json.Unmarshal(body, &data) | |
if err != nil { panic(err) } | |
fmt.Printf("%s", data.Status.Metro.Lines["3"].Message) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment