{"action":"opened","issue":{"url":"https://api.github.com/repos/JohnSundell/Unbox/issues/35","repository_url":"https://api.github.com/repos/JohnSundell/Unbox","labels_url":"https://api.github.com/repos/JohnSundell/Unbox/issues/35/labels{/name}","comments_url":"https://api.github.com/repos/JohnSundell/Unbox/issues/35/comments","events_url":"https://api.github.com/repos/JohnSundell/Unbox/issues/35/events","html_url":"https://github.com/JohnSundell/Unbox/issues/35","id":140891055,"number":35,"title":"Properly unbox an array of different classes/models?","user":{"login":"idevsoftware","id":356357,"avatar_url":"https://avatars.githubusercontent.com/u/356357?v=3","gravatar_id":"","url":"https://api.github.com/users/idevsoftware","html_url":"https://github.com/idevsoftware","followers_url":"https://api.github.com/users/idevsoftware/followers","following_url":"https://api.github.com/users/idevsoftware/following{/other_user}","gists_url":"https://api.github.com/users/idevsoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/idevsoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/idevsoftware/subscriptions","organizations_url":"https://api.github.com/users/idevsoftware/orgs","repos_url":"https://api.github.com/users/idevsoftware/repos","events_url":"https://api.github.com/users/idevsoftware/events{/privacy}","received_events_url":"https://api.github.com/users/idevsoftware/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-03-15T07:02:14Z","updated_at":"2016-03-15T07:02:14Z","closed_at":null,"body":"Hi @JohnSundell. I've been using Unbox during the last few weeks for a new project I'm developing and it works great. Recently I came across a requirement which I'm not entirely sure how to tackle. As part of a JSON response I'm getting an array of dictionaries, each entry corresponding to a member of a local (Unboxable) class I have. However, the exact class type depends on a certain value in the response dictionary:\r\n\r\n```\r\n[\r\n   {\r\n        \"type\": \"someClass\",\r\n        \"common_property\": \"someValue\",\r\n        \"some_property\": \"funnyValue\"\r\n    },\r\n    {\r\n        \"type\": \"anotherClass\",\r\n        \"common_property\": \"anotherValue\",\r\n        \"another_property\": \"sadValue\"\r\n    }\r\n]\r\n\r\n```\r\nWhat I want to achieve is to decode -- sorry, _Unbox_ -- the whole array on a single shot. So far I've failed to do so. It would be great to have some kind of way to tell Unbox to use a particular factory class method on a superclass to initialize and return an instance (which could be of a different subclass type, based on one of the given parameters), without having to resort to manually decode the retrieved data into a local dictionary and then cycle through it. "}}