I have a message from thrift that I would like to be able to serialize into and out of json, but I don't want the generated json keys to match what is in the generated go code.
Is there a way to control what annotations are attached to the struct in the go code that thrift generates?
Scratch my previous answer - it's undocumented, but it IS possible, I found it by reading the compiler code. Bah.
But anyway, in thrift's master (1.0-dev), here's how it's done - using a go.tag
annotation.
This piece of thrift code:
struct foo {
1: string bar (go.tag = "json:\"baz\" yo:\"dawg\""),
2: string bang
}
Generates the following Go code:
type Foo struct {
Bar string `thrift:"bar,1" json:"baz" yo:"dawg"`
Bang string `thrift:"bang,2" json:"bang"`
}