SHARE
TWEET

Untitled

a guest May 19th, 2019 55 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
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top