{"action":"created","issue":{"url":"https://api.github.com/repos/fruux/sabre-xml/issues/105","repository_url":"https://api.github.com/repos/fruux/sabre-xml","labels_url":"https://api.github.com/repos/fruux/sabre-xml/issues/105/labels{/name}","comments_url":"https://api.github.com/repos/fruux/sabre-xml/issues/105/comments","events_url":"https://api.github.com/repos/fruux/sabre-xml/issues/105/events","html_url":"https://github.com/fruux/sabre-xml/pull/105","id":173357554,"number":105,"title":"Updated keyValue deserializer","user":{"login":"snebes","id":666333,"avatar_url":"https://avatars.githubusercontent.com/u/666333?v=3","gravatar_id":"","url":"https://api.github.com/users/snebes","html_url":"https://github.com/snebes","followers_url":"https://api.github.com/users/snebes/followers","following_url":"https://api.github.com/users/snebes/following{/other_user}","gists_url":"https://api.github.com/users/snebes/gists{/gist_id}","starred_url":"https://api.github.com/users/snebes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snebes/subscriptions","organizations_url":"https://api.github.com/users/snebes/orgs","repos_url":"https://api.github.com/users/snebes/repos","events_url":"https://api.github.com/users/snebes/events{/privacy}","received_events_url":"https://api.github.com/users/snebes/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-08-26T02:46:29Z","updated_at":"2016-08-26T21:01:33Z","closed_at":"2016-08-26T03:22:01Z","pull_request":{"url":"https://api.github.com/repos/fruux/sabre-xml/pulls/105","html_url":"https://github.com/fruux/sabre-xml/pull/105","diff_url":"https://github.com/fruux/sabre-xml/pull/105.diff","patch_url":"https://github.com/fruux/sabre-xml/pull/105.patch"},"body":"XML that contains elements that have multiple occurrences are returned as an array of those elements, rather than just the last element in the list.\r\n\r\nGiven this XML:\r\n```\r\n<list>\r\n    <meta>\r\n        ...\r\n    </meta>\r\n    <report>\r\n        <name/>\r\n    </report>\r\n    <report>\r\n        <name/>\r\n    </report>\r\n    <report>\r\n        <name/>\r\n    </report>\r\n    <report>\r\n        <name/>\r\n    </report>\r\n</list>\r\n```\r\nThe resulting object could be returned:\r\n```\r\nSabre Object\r\n(\r\n    [meta] => Meta Object\r\n        (\r\n            ...\r\n        )\r\n    [report] => Array\r\n        (\r\n            [0] => Report Object\r\n                (\r\n                    [title] => Report Title\r\n                )\r\n\r\n            [1] => Report Object\r\n                (\r\n                    [title] => Report Title\r\n                )\r\n\r\n            [2] => Report Object\r\n                (\r\n                    [title] => Report Title\r\n                )\r\n\r\n            [3] => Report Object\r\n                (\r\n                    [title] => Report Title\r\n                )\r\n\r\n            [4] => Report Object\r\n                (\r\n                    [title] => Report Title\r\n                )\r\n```"},"comment":{"url":"https://api.github.com/repos/fruux/sabre-xml/issues/comments/242850600","html_url":"https://github.com/fruux/sabre-xml/pull/105#issuecomment-242850600","issue_url":"https://api.github.com/repos/fruux/sabre-xml/issues/105","id":242850600,"user":{"login":"evert","id":178960,"avatar_url":"https://avatars.githubusercontent.com/u/178960?v=3","gravatar_id":"","url":"https://api.github.com/users/evert","html_url":"https://github.com/evert","followers_url":"https://api.github.com/users/evert/followers","following_url":"https://api.github.com/users/evert/following{/other_user}","gists_url":"https://api.github.com/users/evert/gists{/gist_id}","starred_url":"https://api.github.com/users/evert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evert/subscriptions","organizations_url":"https://api.github.com/users/evert/orgs","repos_url":"https://api.github.com/users/evert/repos","events_url":"https://api.github.com/users/evert/events{/privacy}","received_events_url":"https://api.github.com/users/evert/received_events","type":"User","site_admin":false},"created_at":"2016-08-26T21:01:33Z","updated_at":"2016-08-26T21:01:33Z","body":"Well, my take on this is that both solutions are 'generic enough'. Sure, with Solution 1 you need to write some code to correctly decode this; but the alternative is creating a function that configures a standard deserializer to treat 1 item as a 'one' value, and another as 'many'.\r\n\r\nBut I think the complexity of configuring such a deserializer rivals just writing a custom serialize for it. After all, writing code is a form of configuration.\r\n\r\nI think if \"configuring generic code to do x\" gets close enough to \"write specific code to do x\", it's almost always better to do the second thing, unless you're a Java guy.\r\n\r\nSo if there's a viable generic solution to this problem, it should pass the test that it's actually simpler than a non-generic solution.\r\n\r\nBy the way, did you also consider solution 2? That _is_ actually a generic solution. You're mapping to classes, which give you a number of other benefits. Notably strict typing."}}
{"actor":{"display_login":"evert"}}