aah. Damn it :-) Thanks a lot. I am hitting myself for missing this.
2017-08-09 16:40 GMT+05:30 Jakob Borg :
> On 9 Aug 2017, at 12:26, Sankar wrote:
> >
> > Now for the same, Item object, the json.Marshal function returns two
> different strings for the `Item` object.
> >
> > If you run the pla
On 9 Aug 2017, at 12:26, Sankar wrote:
>
> Now for the same, Item object, the json.Marshal function returns two
> different strings for the `Item` object.
>
> If you run the playground url, you will find that:
>
> {"Items":[{"SD":"2009-11-10T23:00"}]}
> {"Item":{"SD":"2009-11-10T23:00:00Z"}}
Hi,
There is a difference in the way MarshalJSON of a struct is called when an
instance of a struct is either part of an array or embedded directly inside
another object. I am not sure if it is a bug or if it is the intended
behavior.
Please see the Go source available at: https://play.golang