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 <re...@typist.geek.nz 
> > 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-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.


[go-nuts] Re: Language is a platform, which golang still does not pay attention to !!!

2018-04-11 Thread Reed Wade


So -- Go's fatal flaw is you can just deploy your code and run it instead 
of having to first install heaps of libs and config and maybe a jvm first?

I'm certain that's not what was meant but that's how this reads.

I guess the "I don't use Go" bit is the telling part. It doesn't look 
complex and annoying so it must not be effective?

-reed

-- 
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.


[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", "c"}
 j := json.NewEncoder(os.Stdout)
 j.Encode(c)
 j.SetTag("json2") // no such thing as this here
 j.Encode(c)
}


where I've got a struct that I sometimes want to express in json one way 
and sometimes another.

Is there a sensible existing way to do that? Would this be a useful update 
to the lib?

thanks,
-reed

-- 
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.