Don't know how to make 'X' simple, but you can use a strategy like https://play.golang.org/p/n4ms3hNGgy which at least minimizes allocations by only Unmarshal'ing the k:v pairs of interest.
On Tuesday, December 20, 2016 at 8:48:03 AM UTC-7, Alexander Petrovsky wrote: > > Hello! > > By example I have follow json {a:1, b:2, c:str, d:123, ..., z99: 1, z100: > 10}, suppose it's veeery big json, and I don't need the whole fields in my > little struct: > > Struct { > a int `json:"a"` > y int `json:"y"` > } > > What I want? I want smart unmarshaler that can unmarshal my json to > struct, and the other KVs (without 'a' and 'y' fields) put (by example) to > some additional variable X. After some machinery I want to marshal data > back my struct fields and payload from X. How can I do it the most > effective? > > Right now I use map[string]interface{}, but it affetcs my application > latency due it causes many GC. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.