Guest User

Untitled

a guest
May 19th, 2019
57
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package main
  2.  
  3. import (
  4. "encoding/json"
  5. "fmt"
  6. )
  7. func main() {
  8. type inner struct {
  9. Name string `bson: "name" json:"name"`
  10. }
  11.  
  12. type outer struct {
  13. inner
  14. }
  15.  
  16. i := outer{inner{Name: "test"}}
  17.  
  18. b, err := json.Marshal(i)
  19. if err != nil {
  20. fmt.Println(err)
  21. }
  22.  
  23. fmt.Println(string(b)) . // {"name":"test"}
  24. }
RAW Paste Data