Created
October 14, 2013 12:00
-
-
Save froderik/6974542 to your computer and use it in GitHub Desktop.
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
func extractLatLng(data []byte) (float64, float64) { | |
res := make(map[string][]map[string]map[string]map[string]interface{}, 0) | |
json.Unmarshal(data, &res) | |
lat, _ := res["results"][0]["geometry"]["location"]["lat"].(float64) | |
lng, _ := res["results"][0]["geometry"]["location"]["lng"].(float64) | |
return lat, lng | |
} |
Unpacking the JSON into a struct like
type geojson struct {
Results [] struct {
Geometry struct {
Location struct {
Lat float64
Lng float64
}
}
}
}
I believe would work.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The code initiating this twitter thread: https://twitter.com/dgryski/status/389720995902132224.