Re: [go-nuts] JSON dynamic keys

2018-12-03 Thread roger peppe
You might be interested to take a look at how we do it in the elasticsearch client we wrote for one of our services: https://godoc.org/gopkg.in/juju/charmstore.v5/elasticsearch On Mon, 3 Dec 2018 at 15:27, Jeffrey Smith wrote: > I'm trying to set mapping in elastic search in go and want to gene

Re: [go-nuts] JSON dynamic keys

2018-12-03 Thread Diane Looney
In addition to Burak's suggestion, keep in mind that if you implement MarshalJSON and/or UnmarshalJSON for certain structs, then those will be used instead of the built-in functions. If you end up cleaning up your struct definitions and just cant find the right way to annotate your fields to get th

Re: [go-nuts] JSON dynamic keys

2018-12-03 Thread Burak Serdar
On Mon, Dec 3, 2018 at 9:29 AM Burak Serdar wrote: > > On Mon, Dec 3, 2018 at 9:06 AM Jeffrey Smith > wrote: > > > > That is 99% of what I'm after cheers. > > > > I need to be able to set the _doc bit to be any random string if possible > > as its the type name. > > > > `json:"_doc"` > > > Nest

Re: [go-nuts] JSON dynamic keys

2018-12-03 Thread Burak Serdar
On Mon, Dec 3, 2018 at 9:06 AM Jeffrey Smith wrote: > > That is 99% of what I'm after cheers. > > I need to be able to set the _doc bit to be any random string if possible as > its the type name. > > `json:"_doc"` Nested maps are messy to deal with. In my opinion, your best bet is a custom mar

Re: [go-nuts] JSON dynamic keys

2018-12-03 Thread Jeffrey Smith
That is 99% of what I'm after cheers. I need to be able to set the _doc bit to be any random string if possible as its the type name. `json:"_doc"` On Monday, December 3, 2018 at 3:53:34 PM UTC, Burak Serdar wrote: > > On Mon, Dec 3, 2018 at 8:27 AM Jeffrey Smith > > wrote: > > > > I'm try

Re: [go-nuts] JSON dynamic keys

2018-12-03 Thread Burak Serdar
On Mon, Dec 3, 2018 at 8:27 AM Jeffrey Smith wrote: > > I'm trying to set mapping in elastic search in go and want to generate > something like this. > > { "mappings": { "_doc": { "properties": { "title": { "type": "text", "store": > true }, "date": { "type": "date", "store": true }, "content":

[go-nuts] JSON dynamic keys

2018-12-03 Thread Jeffrey Smith
I'm trying to set mapping in elastic search in go and want to generate something like this. { "mappings": { "_doc": { "properties": { "title": { "type": "text", "store": true }, "date": { "type": "date", "store": true }, "content": { "type": "text" } } } } } The _doc, title,date and content a