aryaxt / OCMapper

Objective-C library to easily map NSDictionary to model objects, works perfectly with Alamofire. ObjectMapper works similar to GSON
MIT License
347 stars 45 forks source link

Nested json keys #19

Closed emresebat closed 9 years ago

emresebat commented 9 years ago

Hi

I'm trying to map a composite object like this

   mappingProvider.mapFromDictionaryKey("user.name", toPropertyKey: "name", forClass: User.self)

But it doesn't map, nested keys are not supported?

aryaxt commented 9 years ago

Can you post the model, and json structure?

emresebat commented 9 years ago

Hi

Json

{
   "visibleByAnonymousUsers":{
      "active":true,
      "createdAt":"2014-11-09T18:22:52.168+0000",
      "email":"REMOVED",
      "firstName":"REMOVED",
      "fullName":"REMOVED",
      "lastName":"REMOVED",
      "parseId":"OXsGz9b9NN",
      "updatedAt":"2015-02-12T09:42:31.722+0000"
   },
   "user":{
      "name":"REMOVED",
      "roles":[
         {
            "name":"administrator",
            "isrole":true
         }
      ],
      "status":"ACTIVE"
   },
   "visibleByTheUser":{

   },
   "visibleByFriends":{

   },
   "visibleByRegisteredUsers":{
      "_social":{

      }
   },
   "signUpDate":"2015-02-23T00:20:59.889+0000",
   "generated_username":false
}

Model

import UIKit

class KSUser: KSRLMObject {
    dynamic var name = ""
    dynamic var fullName = ""
    dynamic var email = ""   

}

So I try to map like this

mappingProvider.mapFromDictionaryKey("user.name", 
                             toPropertyKey: "name", forClass: KSUser.self)
mappingProvider.mapFromDictionaryKey("visibleByAnonymousUsers.fullName", 
                            toPropertyKey: "fullName", forClass: KSUser.self)
aryaxt commented 9 years ago

Unfortunately that's not supported