{"action":"created","issue":{"url":"https://api.github.com/repos/evermeer/AlamofireJsonToObjects/issues/4","labels_url":"https://api.github.com/repos/evermeer/AlamofireJsonToObjects/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/evermeer/AlamofireJsonToObjects/issues/4/comments","events_url":"https://api.github.com/repos/evermeer/AlamofireJsonToObjects/issues/4/events","html_url":"https://github.com/evermeer/AlamofireJsonToObjects/issues/4","id":102242603,"number":4,"title":"Generic list parse","user":{"login":"sagits","id":6174566,"avatar_url":"https://avatars.githubusercontent.com/u/6174566?v=3","gravatar_id":"","url":"https://api.github.com/users/sagits","html_url":"https://github.com/sagits","followers_url":"https://api.github.com/users/sagits/followers","following_url":"https://api.github.com/users/sagits/following{/other_user}","gists_url":"https://api.github.com/users/sagits/gists{/gist_id}","starred_url":"https://api.github.com/users/sagits/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sagits/subscriptions","organizations_url":"https://api.github.com/users/sagits/orgs","repos_url":"https://api.github.com/users/sagits/repos","events_url":"https://api.github.com/users/sagits/events{/privacy}","received_events_url":"https://api.github.com/users/sagits/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-08-20T21:33:52Z","updated_at":"2015-08-22T07:32:49Z","closed_at":null,"body":"Hi, im trying to parse a generic list, i think that there is no support for it for now, but is there any way i can use setValue forUndefinedKey function to pass a class type and be able to parse the list? Maybe is there another way? Thanks in advance.\r\n\r\nWhat i have now:\r\n\r\n    class JsonMessage : EVObject {\r\n      var _meta : MetaModel\r\n\r\n      override\r\n      init() {\r\n          _meta = MetaModel()\r\n      }\r\n    } \r\n\r\n\r\n    class JsonMessageList<T> : JsonMessage {\r\n      var records = [T]()\r\n\r\n      override\r\n      init() {\r\n\r\n      }\r\n\r\n    }\r\n\r\n```\r\n   Alamofire.request(.GET, URL, headers: headers)\r\n            .responseObject { (response: JsonMessageList<ProductModel>?, error: NSError?) in\r\n               if (error == nil && response != nil) {\r\n                   for product in response!.records {\r\n                       println(\"id: \" + product.name!);\r\n                   }\r\n                }\r\n                else {\r\n                    println(\"Error on request\");\r\n                }\r\n            }\r\n```\r\n\r\n Im an Android Developer, and i have created a lib that does this on android.\r\nI pass a Model.class (Class<T>) to a ListHelperModel and use this list as a type for gson (a google library that parse json to objects) to parse the list.\r\n\r\nTake a look if you want:\r\n\r\n [ListHelperModel](https://github.com/sagits/android-fast-dao/blob/master/app/src/main/java/rockapps/com/fastrestdao/dao/framework/JsonListHelper.java)\r\n\r\n [Check getList() method](https://github.com/sagits/android-fast-dao/blob/master/app/src/main/java/rockapps/com/fastrestdao/dao/framework/CallListListener.java)\r\n\r\n\r\nUnfortunelly im very new to swift/ios, so i just dont know how and if i can reproduce this.\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/evermeer/AlamofireJsonToObjects/issues/comments/133648654","html_url":"https://github.com/evermeer/AlamofireJsonToObjects/issues/4#issuecomment-133648654","issue_url":"https://api.github.com/repos/evermeer/AlamofireJsonToObjects/issues/4","id":133648654,"user":{"login":"evermeer","id":130834,"avatar_url":"https://avatars.githubusercontent.com/u/130834?v=3","gravatar_id":"","url":"https://api.github.com/users/evermeer","html_url":"https://github.com/evermeer","followers_url":"https://api.github.com/users/evermeer/followers","following_url":"https://api.github.com/users/evermeer/following{/other_user}","gists_url":"https://api.github.com/users/evermeer/gists{/gist_id}","starred_url":"https://api.github.com/users/evermeer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evermeer/subscriptions","organizations_url":"https://api.github.com/users/evermeer/orgs","repos_url":"https://api.github.com/users/evermeer/repos","events_url":"https://api.github.com/users/evermeer/events{/privacy}","received_events_url":"https://api.github.com/users/evermeer/received_events","type":"User","site_admin":false},"created_at":"2015-08-22T07:32:49Z","updated_at":"2015-08-22T07:32:49Z","body":"I was wrong. It should just work. I created a new unit test that shows this. Here it is:\r\nhttps://github.com/evermeer/EVReflection/blob/c0de1d56f2589df7c0650a33ddb06b539a116d2b/EVReflection/EVReflectionTests/WorkaroundSwiftGenericsTests.swift#L25-35\r\n\r\nIn your json, do you have a root object with the property records which will contain an array of your product model records? So something like this: {\"records\":[{\"property\":\"value\"},{\"property\":\"value2\"}]}\r\nOr is the root of the json already an array? like this: [{\"property\":\"value\"},{\"property\":\"value2\"}]\r\nIf so, then you need to use .responseArray instead of .responseObject"}}