{"action":"created","issue":{"url":"https://api.github.com/repos/michalmuskala/jason/issues/62","repository_url":"https://api.github.com/repos/michalmuskala/jason","labels_url":"https://api.github.com/repos/michalmuskala/jason/issues/62/labels{/name}","comments_url":"https://api.github.com/repos/michalmuskala/jason/issues/62/comments","events_url":"https://api.github.com/repos/michalmuskala/jason/issues/62/events","html_url":"https://github.com/michalmuskala/jason/pull/62","id":380401250,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMwNjA4MjEw","number":62,"title":"allows for encoding keyword lists","user":{"login":"isaac-rstor","id":29075198,"node_id":"MDQ6VXNlcjI5MDc1MTk4","avatar_url":"https://avatars2.githubusercontent.com/u/29075198?v=4","gravatar_id":"","url":"https://api.github.com/users/isaac-rstor","html_url":"https://github.com/isaac-rstor","followers_url":"https://api.github.com/users/isaac-rstor/followers","following_url":"https://api.github.com/users/isaac-rstor/following{/other_user}","gists_url":"https://api.github.com/users/isaac-rstor/gists{/gist_id}","starred_url":"https://api.github.com/users/isaac-rstor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isaac-rstor/subscriptions","organizations_url":"https://api.github.com/users/isaac-rstor/orgs","repos_url":"https://api.github.com/users/isaac-rstor/repos","events_url":"https://api.github.com/users/isaac-rstor/events{/privacy}","received_events_url":"https://api.github.com/users/isaac-rstor/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-11-13T20:07:01Z","updated_at":"2018-11-14T19:08:33Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/michalmuskala/jason/pulls/62","html_url":"https://github.com/michalmuskala/jason/pull/62","diff_url":"https://github.com/michalmuskala/jason/pull/62.diff","patch_url":"https://github.com/michalmuskala/jason/pull/62.patch"},"body":"This is useful if one wants to do:\r\n```\r\n%Struct{...}\r\n|> Map.from_struct\r\n|> Enum.<tranformation1>\r\n|> Enum.<transformation2>\r\n|> Jason.Encode.keyword(opts)\r\n```\r\ninside of a `defimpl`, which lets you segregate all of your JSON marshalling to an external API in one place.\r\n\r\nPros:\r\nNo need to do a costly `Enum.into(%{})` only to `Map.to_list()` later anyways.\r\n\r\nCons:\r\nIntroduces a guard into the passed encode_map() function, there may be a performance hit that everyone pays. Seems mostly useful for only a small subset of Ecto schema transformations (where you are `defimpl`'ing externally).\r\n\r\nRefactoring opportunities:\r\nMight consider DRYing keyword_naive/map_naive, keyword_strict/map_strict into a single function and guarding Map.to_list instead.\r\n"},"comment":{"url":"https://api.github.com/repos/michalmuskala/jason/issues/comments/438781468","html_url":"https://github.com/michalmuskala/jason/pull/62#issuecomment-438781468","issue_url":"https://api.github.com/repos/michalmuskala/jason/issues/62","id":438781468,"node_id":"MDEyOklzc3VlQ29tbWVudDQzODc4MTQ2OA==","user":{"login":"isaac-rstor","id":29075198,"node_id":"MDQ6VXNlcjI5MDc1MTk4","avatar_url":"https://avatars2.githubusercontent.com/u/29075198?v=4","gravatar_id":"","url":"https://api.github.com/users/isaac-rstor","html_url":"https://github.com/isaac-rstor","followers_url":"https://api.github.com/users/isaac-rstor/followers","following_url":"https://api.github.com/users/isaac-rstor/following{/other_user}","gists_url":"https://api.github.com/users/isaac-rstor/gists{/gist_id}","starred_url":"https://api.github.com/users/isaac-rstor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isaac-rstor/subscriptions","organizations_url":"https://api.github.com/users/isaac-rstor/orgs","repos_url":"https://api.github.com/users/isaac-rstor/repos","events_url":"https://api.github.com/users/isaac-rstor/events{/privacy}","received_events_url":"https://api.github.com/users/isaac-rstor/received_events","type":"User","site_admin":false},"created_at":"2018-11-14T19:08:33Z","updated_at":"2018-11-14T19:08:33Z","author_association":"NONE","body":"I also did a slightly more aggressive refactoring, which alters map_naive and map_strict themselves to take a  keyword list as the first parameter, both versions pass unit tests, I think there should be almost no performance penalty since the check happens on the case() statement anyways, but the code is *slightly* harder to understand."}}
{"actor":{"display_login":"isaac-rstor"}}