Skip to content

Instantly share code, notes, and snippets.

@tokubass
Created November 22, 2018 03:08
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 tokubass/d0fcf81ac58dcef937938d112d5d4365 to your computer and use it in GitHub Desktop.
Save tokubass/d0fcf81ac58dcef937938d112d5d4365 to your computer and use it in GitHub Desktop.
marshal_template
package main
import (
"encoding/json"
"fmt"
)
type Foo struct {
ID uint64 `json:"ID"`
}
func main() {
jsonStr := []byte("{ \"ID\": 18446744073709551615 }")
var f Foo
err := json.Unmarshal(jsonStr, &f)
if err != nil {
panic(err)
}
fmt.Printf("%+v\n", f)
out, _ := json.Marshal(f)
fmt.Println("JSON representation:", string(out))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment