{"action":"created","issue":{"url":"https://api.github.com/repos/google/protobuf/issues/1922","repository_url":"https://api.github.com/repos/google/protobuf","labels_url":"https://api.github.com/repos/google/protobuf/issues/1922/labels{/name}","comments_url":"https://api.github.com/repos/google/protobuf/issues/1922/comments","events_url":"https://api.github.com/repos/google/protobuf/issues/1922/events","html_url":"https://github.com/google/protobuf/pull/1922","id":169414211,"number":1922,"title":"JavaScript: Make implicit defaults consistent with explicit defaults in toObject","user":{"login":"seishun","id":988441,"avatar_url":"https://avatars.githubusercontent.com/u/988441?v=3","gravatar_id":"","url":"https://api.github.com/users/seishun","html_url":"https://github.com/seishun","followers_url":"https://api.github.com/users/seishun/followers","following_url":"https://api.github.com/users/seishun/following{/other_user}","gists_url":"https://api.github.com/users/seishun/gists{/gist_id}","starred_url":"https://api.github.com/users/seishun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seishun/subscriptions","organizations_url":"https://api.github.com/users/seishun/orgs","repos_url":"https://api.github.com/users/seishun/repos","events_url":"https://api.github.com/users/seishun/events{/privacy}","received_events_url":"https://api.github.com/users/seishun/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/google/protobuf/labels/cla:%20yes","name":"cla: yes","color":"009800"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-08-04T16:16:03Z","updated_at":"2016-10-14T21:00:43Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/google/protobuf/pulls/1922","html_url":"https://github.com/google/protobuf/pull/1922","diff_url":"https://github.com/google/protobuf/pull/1922.diff","patch_url":"https://github.com/google/protobuf/pull/1922.patch"},"body":"This was originally part of #1447, but it was decided to postpone this part. The relevant parts of the description of the previous PR follow.\r\n\r\nCurrently, the JS implementation treats proto2 fields with specified defaults differently from fields without specified defaults in `toObject`.\r\n\r\nConsider the following message definition:\r\n\r\n```proto\r\nmessage Test {\r\n  optional string foo = 1;\r\n  optional string bar = 2 [default = \"\"];\r\n}\r\n```\r\n\r\nIf both `foo` and `bar` are unset, `toObject()` returns `{ foo: undefined, bar: \"\" }`.\r\n\r\nHowever, `foo` and `bar` should be equivalent when unset per the [spec](https://developers.google.com/protocol-buffers/docs/proto#optional) (which would be consistent with the other implementations). I propose to unify their behavior in the following way:\r\n\r\nIf both `foo` and `bar` are unset, `toObject()` returns `{}`. This is for two reasons: 1) putting the default value in the object would cause loss of presence information; 2) properties with `undefined` values don't carry any useful information and just add noise to the object."},"comment":{"url":"https://api.github.com/repos/google/protobuf/issues/comments/253918101","html_url":"https://github.com/google/protobuf/pull/1922#issuecomment-253918101","issue_url":"https://api.github.com/repos/google/protobuf/issues/1922","id":253918101,"user":{"login":"googlebot","id":5384588,"avatar_url":"https://avatars.githubusercontent.com/u/5384588?v=3","gravatar_id":"","url":"https://api.github.com/users/googlebot","html_url":"https://github.com/googlebot","followers_url":"https://api.github.com/users/googlebot/followers","following_url":"https://api.github.com/users/googlebot/following{/other_user}","gists_url":"https://api.github.com/users/googlebot/gists{/gist_id}","starred_url":"https://api.github.com/users/googlebot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/googlebot/subscriptions","organizations_url":"https://api.github.com/users/googlebot/orgs","repos_url":"https://api.github.com/users/googlebot/repos","events_url":"https://api.github.com/users/googlebot/events{/privacy}","received_events_url":"https://api.github.com/users/googlebot/received_events","type":"User","site_admin":false},"created_at":"2016-10-14T21:00:43Z","updated_at":"2016-10-14T21:00:43Z","body":"CLAs look good, thanks!\n\n<!-- ok -->"}}
{"actor":{"display_login":"googlebot"}}