[go-nuts] alternate struct tags for json encode/decode?

2018-04-11 Thread Reed Wade
More than once, I've found myself wanting to do something like this: package main import ( "encoding/json" "os" ) type Cake struct { Muffin string `json:"muffin" json2:"muffin"` Piestring `json:"pie" json2:"-"` Tuna string `json:"tuna" json2:"eel"` } func main() { c := Cake{"a", "b"

Re: [go-nuts] alternate struct tags for json encode/decode?

2018-04-11 Thread Jan Mercl
On Wed, Apr 11, 2018 at 2:50 PM Reed Wade wrote: > Is there a sensible existing way to do that? Would this be a useful update to the lib? Not very nice, but: https://play.golang.org/p/gkWEuV1AlwB -- -j -- You received this message because you are subscribed to the Google Groups "golang-nu

Re: [go-nuts] alternate struct tags for json encode/decode?

2018-04-11 Thread Reed Wade
oh, cool! I had no idea that was doable (makes sense in retrospect but..). That would kind of suit a lot of the cases I care about. thanks, -reed On Thursday, 12 April 2018 00:57:20 UTC+12, Jan Mercl wrote: > > On Wed, Apr 11, 2018 at 2:50 PM Reed Wade > wrote: > > > Is there a sensible exi

Re: [go-nuts] alternate struct tags for json encode/decode?

2018-04-11 Thread Timothy Raymond
It wasn’t always possible. I think this ability was added around 1.8 to expressly make multiple “views” of a struct easier by ignoring tags in the identity of the struct: https://go-review.googlesource.com/c/go/+/30169 -- You received this message because you are subscribed to the Google Groups