Skip to content

encoding/json: RawMessage should marshal without pointer receiver #6528

@augustoroman

Description

@augustoroman
The current json.RawMessage implementation defines MarshalJSON on a pointer receiver. 
This causes unexpected behavior when marshalling with non-pointer-receiver objects.

For example:
http://play.golang.org/p/Cf_6zpIKC0

Instead, MarshalJSON should be defined on a non-pointer receiver for json.RawMessage. 
This will continue to work for existing code that uses pointer-receivers, but will
change behavior to work "correctly" on code that accidentally uses
non-pointer-receivers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions