2011-12-06 5 views
0

어떻게 매핑 나는이 같은 JSON 응답있어 경우처럼 동작하지 않습니다RestKit : JSON 매핑

{ 
"persons":{ 
    "@size":"4", 
    "person":[ 
    { 
     "name":"John", 
     "type":"Doe 1", 
     "options":"some options" 
    }, 
    { 
     "name":"John", 
     "type":"Doe 2", 
     "options":"some other options" 
    }, 
    { 
     "name":"John", 
     "type":"Doe 3", 
    }, 
    { 
     "name":"John", 
     "type":"Doe 4", 
    } 
    ] 
} 
} 

은 이미 다음과 같은 매핑을 시도,하지만 작동하지 않습니다

RKManagedObjectMapping* personMapping = [RKManagedObjectMapping mappingForClass:[CDCustomFieldDefinition class]]; 
[personMapping mapKeyPath:@"label" toAttribute:@"label"]; 
[personMapping mapKeyPath:@"type" toAttribute:@"type"]; 
[personMapping mapKeyPath:@"options" toAttribute:@"options"]; 
personMapping.primaryKeyAttribute = @"label"; 

[[RKObjectManager sharedManager].mappingProvider setMapping:personMapping forKeyPath:@"persons"]; 

didLoadObjects:에있는 내 개체 배열은 항상 비어 있습니다 ... 아이디어가 있습니까? 고마워요!

답변

3

는 키 패스가

@"persons.person" 
+0

가 대단히 감사합니다 할 경우, 그것을 작동합니다! 나는'@ "persons/person"'로 시도했지만, dot 문법으로 시도한 적이 없다 ... 감사합니다! – swalkner

+0

@swalkner : 운 좋은 추측 :) – JeremyP