No, no need to export, unless fields have weird names. Fields must be with capital letters:
https://play.golang.org/p/zMeKqW-4JT9 On Wednesday, October 31, 2018 at 11:12:05 PM UTC-7, kortschak wrote: > > https://play.golang.org/p/Se8wXfYZVZG > > You need to export the field: > ``` > Struct values encode as JSON objects. Each exported struct field > becomes a member of the object, using the field name as the object key, > unless the field is omitted for one of the reasons given below. > ``` > > On Wed, 2018-10-31 at 23:07 -0700, Alex Dvoretskiy wrote: > > How can I get this json in output? > > > > [ > > { > > "s": 123, > > "id": "adsfasdf" > > }, > > { > > "s": 123, > > "id": "sefascss" > > } > > ] > > > > https://play.golang.org/p/AHcUO5IuByf > > > > > -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
