2012-06-28 2 views
1

에 빈 배열을 구문 분석하는 동안 다음과 같은 JSON 구조가 있습니다오류 RestKit

{"projekt":{ 
    "id":18, 
    "projectname":"test", 
    "dokumente":{ 
     "id":1190, 
     "name":"rootfolder", 
     "information":{ 
      "folder":[ 
       { 
        "id":1191, 
        "name":"folder 1", 
        "information":"" 
       }, 
       { 
        "id":1198, 
        "name":"folder 2", 
        "information":{ 
         "folder":[ 
          { 
           "id":1199, 
           "name":"folder 2 1", 
           "information":"" 
          }, 
          { 
           "id":1199, 
           "name":"folder 2 2", 
           "information":"" 
          } 
         ] 
        } 
       } 
      ] 
     } 
    } 
}} 

는 기본적으로 재귀 폴더 구조입니다. 프로젝트, 정보 및 폴더에 대한 RKObjectMappings이 있습니다. 구문 분석은 information=""에 도달 할 때까지 계속됩니다. RestKit 이제 sourceKeyPath이 information 요소에 사용할 수 없습니다 folder 때문이 실패 라인 (442) RKObjectMappingOperation에서

value = [self.sourceObject valueForKeyPath:relationshipMapping.sourceKeyPath]; 

, 전화를 시도합니다. 이로 인해 NSUnknownKeyException이 발생하고 구문 분석이 중지됩니다.

내가 원하는 것은 RestKit은 정보 요소를 무시하고 그것을 nil로 설정한다는 것입니다. 이것을 어떻게 할 수 있습니까?

답변

1

[informationMapping setIgnoreUnknownKeyPaths:YES];을 깜박했습니다. 이것이 설정되면 예외는 무시되고 값 nil이 무시됩니다. 좋은!

+0

빈 배열이 null 인 경우 (예 : "정보": null. setIgnoreUnkownKeyPaths : 예, 시도했지만 null 개체를 처리하는 것 같지 않습니다. 어떤 아이디어? –