[go-nuts] Re: Golang JSONObject

2021-12-23 Thread 'Soufien Benramdhane' via golang-nuts
Hi A JI, Here the documentation linked to json.Unmarshal : https://pkg.go.dev/encoding/json#Marshal It works only exported fields. Since your field *price* is unexported, Marshal would just ignore it. You should probably try this: https://go.dev/play/p/49Zm1fawC9F Using an intermediate anonym

[go-nuts] Re: Golang JSONObject

2021-12-23 Thread Kevin Chowski
This is not a real "why", but this how json.Marshal works according to the documentation. From https://pkg.go.dev/encoding/json#Marshal: "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