{"action":"created","issue":{"url":"https://api.github.com/repos/serde-rs/serde/issues/43","labels_url":"https://api.github.com/repos/serde-rs/serde/issues/43/labels{/name}","comments_url":"https://api.github.com/repos/serde-rs/serde/issues/43/comments","events_url":"https://api.github.com/repos/serde-rs/serde/issues/43/events","html_url":"https://github.com/serde-rs/serde/issues/43","id":63257334,"number":43,"title":"JSON serialization could skip serializing \"null\" fields","user":{"login":"erickt","id":84711,"avatar_url":"https://avatars.githubusercontent.com/u/84711?v=3","gravatar_id":"","url":"https://api.github.com/users/erickt","html_url":"https://github.com/erickt","followers_url":"https://api.github.com/users/erickt/followers","following_url":"https://api.github.com/users/erickt/following{/other_user}","gists_url":"https://api.github.com/users/erickt/gists{/gist_id}","starred_url":"https://api.github.com/users/erickt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erickt/subscriptions","organizations_url":"https://api.github.com/users/erickt/orgs","repos_url":"https://api.github.com/users/erickt/repos","events_url":"https://api.github.com/users/erickt/events{/privacy}","received_events_url":"https://api.github.com/users/erickt/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-20T16:18:48Z","updated_at":"2016-01-13T14:41:19Z","closed_at":null,"body":"Right now we serialize a type like:\r\n\r\n```rust\r\nstruct Foo {\r\n    x: ()\r\n}\r\n```\r\n\r\nAs:\r\n\r\n```json\r\n{\"x\": null}\r\n```\r\n\r\nBut many json deserializers (like serde) support treating missing fields as a `null` value. If we could do this efficiently in serde, then we could cut down on the size of our serialized output. Unfortunately this would require us to add some form of lookahead to `Serializer`, which might be tricky."},"comment":{"url":"https://api.github.com/repos/serde-rs/serde/issues/comments/171311386","html_url":"https://github.com/serde-rs/serde/issues/43#issuecomment-171311386","issue_url":"https://api.github.com/repos/serde-rs/serde/issues/43","id":171311386,"user":{"login":"oli-obk","id":332036,"avatar_url":"https://avatars.githubusercontent.com/u/332036?v=3","gravatar_id":"","url":"https://api.github.com/users/oli-obk","html_url":"https://github.com/oli-obk","followers_url":"https://api.github.com/users/oli-obk/followers","following_url":"https://api.github.com/users/oli-obk/following{/other_user}","gists_url":"https://api.github.com/users/oli-obk/gists{/gist_id}","starred_url":"https://api.github.com/users/oli-obk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oli-obk/subscriptions","organizations_url":"https://api.github.com/users/oli-obk/orgs","repos_url":"https://api.github.com/users/oli-obk/repos","events_url":"https://api.github.com/users/oli-obk/events{/privacy}","received_events_url":"https://api.github.com/users/oli-obk/received_events","type":"User","site_admin":false},"created_at":"2016-01-13T14:41:19Z","updated_at":"2016-01-13T14:41:19Z","body":"Copying your comment from the PR here, so it's not lost\r\n\r\n> Another option would be when serializing fields, the Serializer passes an outer closure to the Serialize impl. If it decides to serialize the value, then it passes an inner closure to outer one. The outer one actually serializes the field name, then calls the inner one to do the actual serialization. Not calling the closure is equivalent to not serializing the key-value pair."}}