Skip to content

Instantly share code, notes, and snippets.

@froderik
Created October 14, 2013 12:00
Show Gist options
  • Save froderik/6974542 to your computer and use it in GitHub Desktop.
Save froderik/6974542 to your computer and use it in GitHub Desktop.
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
}
@dgryski
Copy link

dgryski commented Oct 14, 2013

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