Skip to content

Instantly share code, notes, and snippets.

@meson10
Created May 23, 2016 07:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meson10/f177475c73dd595afaf6f7875f047009 to your computer and use it in GitHub Desktop.
Save meson10/f177475c73dd595afaf6f7875f047009 to your computer and use it in GitHub Desktop.
Go behaves weirdly with int64 being marshalled out of interfaces
package main
import (
"fmt"
"encoding/json"
)
type Data map[string]interface{}
func main() {
var data Data
body := []byte("{\"id\":4418489049307132905}")
if err := json.Unmarshal(body, &data); err != nil {
panic(err)
}
tag_id := data["id"].(int64)
fmt.Println(tag_id)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment