Skip to content

Instantly share code, notes, and snippets.

@minikomi
Created June 1, 2012 07:38
Show Gist options
  • Save minikomi/2849988 to your computer and use it in GitHub Desktop.
Save minikomi/2849988 to your computer and use it in GitHub Desktop.
Exporting and manipulating tagged json fields in golang
package main
import "fmt"
import "encoding/json"
type Test struct {
Test1 string
Test2 string `json:"special_json_name"`
test3 string
}
func main() {
a := Test{"hi", "yeah", "can't be exported :("}
a.Test2 = "whatttt!"
b, _ := json.Marshal(a)
fmt.Println(string(b))
}
{
"Test1":"hi",
"special_json_name":"whatttt!"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment