{"action":"opened","issue":{"url":"https://api.github.com/repos/coreos/go-oidc/issues/69","repository_url":"https://api.github.com/repos/coreos/go-oidc","labels_url":"https://api.github.com/repos/coreos/go-oidc/issues/69/labels{/name}","comments_url":"https://api.github.com/repos/coreos/go-oidc/issues/69/comments","events_url":"https://api.github.com/repos/coreos/go-oidc/issues/69/events","html_url":"https://github.com/coreos/go-oidc/issues/69","id":144658535,"number":69,"title":"Define MarshalJSON on concrete types, not pointer","user":{"login":"ericchiang","id":2342749,"avatar_url":"https://avatars.githubusercontent.com/u/2342749?v=3","gravatar_id":"","url":"https://api.github.com/users/ericchiang","html_url":"https://github.com/ericchiang","followers_url":"https://api.github.com/users/ericchiang/followers","following_url":"https://api.github.com/users/ericchiang/following{/other_user}","gists_url":"https://api.github.com/users/ericchiang/gists{/gist_id}","starred_url":"https://api.github.com/users/ericchiang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericchiang/subscriptions","organizations_url":"https://api.github.com/users/ericchiang/orgs","repos_url":"https://api.github.com/users/ericchiang/repos","events_url":"https://api.github.com/users/ericchiang/events{/privacy}","received_events_url":"https://api.github.com/users/ericchiang/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-03-30T17:20:34Z","updated_at":"2016-03-30T17:20:34Z","closed_at":null,"body":"Brought this up in #68.\r\n\r\nDefining a type like so\r\n\r\n```go\r\nfunc (b *Bar) MarshalJSON() ([]byte, error) {\r\n\t// ...\r\n}\r\n```\r\n\r\nMeans that this is an error\r\n\r\n```go\r\nb := Bar{}\r\njson.Marshal(b) // Passing concrete type, not pointer\r\n``` \r\n\r\nHowever defining `MarshalJSON` on the concrete type causes `json.Marshal` to work fine on either the concrete type or pointer.\r\n\r\n```go\r\nfunc (f Foo) MarshalJSON() ([]byte, error) {\r\n\t// ...\r\n}\r\n\r\nf := Foo{}\r\njson.Marshal(&f) // Passing pointer, this totally works. \r\n```\r\n\r\nSee example here: https://play.golang.org/p/fv5MFSk15X\r\n\r\nI propose moving all of our definitions to define MarshalJSON on a concrete receiver rather than a pointer."}}