{"action":"created","issue":{"url":"https://api.github.com/repos/gogo/protobuf/issues/393","repository_url":"https://api.github.com/repos/gogo/protobuf","labels_url":"https://api.github.com/repos/gogo/protobuf/issues/393/labels{/name}","comments_url":"https://api.github.com/repos/gogo/protobuf/issues/393/comments","events_url":"https://api.github.com/repos/gogo/protobuf/issues/393/events","html_url":"https://github.com/gogo/protobuf/pull/393","id":305530284,"number":393,"title":"Add to jsonpb.Marshaller option to flatten embedded messages","user":{"login":"dotpy3","id":8390508,"avatar_url":"https://avatars0.githubusercontent.com/u/8390508?v=4","gravatar_id":"","url":"https://api.github.com/users/dotpy3","html_url":"https://github.com/dotpy3","followers_url":"https://api.github.com/users/dotpy3/followers","following_url":"https://api.github.com/users/dotpy3/following{/other_user}","gists_url":"https://api.github.com/users/dotpy3/gists{/gist_id}","starred_url":"https://api.github.com/users/dotpy3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotpy3/subscriptions","organizations_url":"https://api.github.com/users/dotpy3/orgs","repos_url":"https://api.github.com/users/dotpy3/repos","events_url":"https://api.github.com/users/dotpy3/events{/privacy}","received_events_url":"https://api.github.com/users/dotpy3/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-03-15T12:22:17Z","updated_at":"2018-03-17T12:37:00Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/gogo/protobuf/pulls/393","html_url":"https://github.com/gogo/protobuf/pull/393","diff_url":"https://github.com/gogo/protobuf/pull/393.diff","patch_url":"https://github.com/gogo/protobuf/pull/393.patch"},"body":"This PR closes #211, by adding an option to flatten embedded messages when (un)marshalling with `jsonpb`.\r\n\r\nThis option can be enabled with a new boolean flag in the marshaller, `jsonpb.Marshaller.EmbedAsStdJSON`. When this flag is enabled, if a struct field is `embed` and follows the `encoding/json` conditions to be flattened (no JSON tag or name), it is flattened.\r\n\r\nFor example, here are Protobuf messages that were added to the test suite:\r\n\r\n```proto\r\nmessage Town {\r\n  required string name = 1;\r\n  required string postcode = 2;\r\n}\r\n\r\nmessage Address {\r\n  required Town town = 1 [(gogoproto.embed) = true, (gogoproto.nullable) = false, (gogoproto.jsontag) = \"\"];\r\n  required string street = 2;\r\n}\r\n```\r\n\r\nWhen marshalling an `Address` with `jsonpb.Marshaller` with this `EmbedAsStdJSON` flag enabled, the marshaller will return messages in this format:\r\n\r\n```json\r\n{\"postcode\": <postcode>, \"street\": <street>, \"name\": <name>}\r\n```\r\n\r\nWhereas it used to marshall it to the following format:\r\n\r\n```json\r\n{\"town\":{\"postcode\": <postcode>, \"name\": <name>}, \"street\": <street>}\r\n```\r\n\r\nNo flag was added to the unmarshaller: the unmarshaller can also now unmarshal both flattened and non-flattened JSONs.\r\n\r\nLet me know if I missed anything when creating this PR, or if you'd like to see anything fixed!\r\n\r\ncc @htdvisser @gomezjdaniel"},"comment":{"url":"https://api.github.com/repos/gogo/protobuf/issues/comments/373916962","html_url":"https://github.com/gogo/protobuf/pull/393#issuecomment-373916962","issue_url":"https://api.github.com/repos/gogo/protobuf/issues/393","id":373916962,"user":{"login":"awalterschulze","id":1829933,"avatar_url":"https://avatars3.githubusercontent.com/u/1829933?v=4","gravatar_id":"","url":"https://api.github.com/users/awalterschulze","html_url":"https://github.com/awalterschulze","followers_url":"https://api.github.com/users/awalterschulze/followers","following_url":"https://api.github.com/users/awalterschulze/following{/other_user}","gists_url":"https://api.github.com/users/awalterschulze/gists{/gist_id}","starred_url":"https://api.github.com/users/awalterschulze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/awalterschulze/subscriptions","organizations_url":"https://api.github.com/users/awalterschulze/orgs","repos_url":"https://api.github.com/users/awalterschulze/repos","events_url":"https://api.github.com/users/awalterschulze/events{/privacy}","received_events_url":"https://api.github.com/users/awalterschulze/received_events","type":"User","site_admin":false},"created_at":"2018-03-17T12:37:00Z","updated_at":"2018-03-17T12:37:00Z","author_association":"OWNER","body":"I have fixed the GopherJS problems on master."}}
{"actor":{"display_login":"awalterschulze"}}