Created
May 23, 2016 07:18
-
-
Save meson10/f177475c73dd595afaf6f7875f047009 to your computer and use it in GitHub Desktop.
Go behaves weirdly with int64 being marshalled out of interfaces
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 ( | |
"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