1

I've to parse a nested JSON object posted below. It am not getting any test objects back.What is it that I am doing incorrectly?

{"tests":[{"type":"QA","list":[{"test_performed":{"id":11,"time":" 9:00 AM","tester":"Tester 1"}}]},{"type":"BAT","list":[]},{"type":"UAT","list":[]}],"tested":"true"}

Objects created:

Result
NSArray *tests;
NSNumber *tested;

TestTypeList
NSArray *list;
NSString *type;

Test
NSNumber *identifier
NSString *start_time;
NSString *tester;

RKObjectMapping *testMapping=[RKObjectMapping mappingForClass:[Test class]];
[testMapping mapKeyPath:@"id" toAttribute:@"identifier"];
[testMapping mapKeyPath:@"time" toAttribute:@"time"];
[testMapping mapKeyPath:@"tester" toAttribute:@"tester"];
[[RKObjectManager sharedManager].mappingProvider setMapping:testMapping forKeyPath:@"test_performed"];

RKObjectMapping *testInverseMapping = [testMapping inverseMapping];
testInverseMapping.rootKeyPath = @"test_performed";

[[RKObjectManager sharedManager].mappingProvider setSerializationMapping:timeInverseMapping forClass:[Time class]];

RKObjectMapping *testTypeListMapping=[RKObjectMapping mappingForClass:[TestTypeList class]];
[testTypeListMapping mapKeyPath:@"type" toAttribute:@"type"];
[testTypeListMapping mapKeyPath:@"list" toRelationship:@"list" withMapping:testMapping];

[[RKObjectManager sharedManager].mappingProvider testTypeListMapping forKeyPath:@"tests"];

RKObjectMapping *testTypeListInverseMapping = [testTypeListMapping inverseMapping];
testTypeListInverseMapping.rootKeyPath = @"tests";

[[RKObjectManager sharedManager].mappingProvider setSerializationMapping:testTypeInverseMapping forClass:[TestTypeList class]];

RKObjectMapping *resultMapping=[RKObjectMapping mappingForClass:[Result class]];
[resultMapping mapKeyPath:@"tested" toAttribute:@"tested"];
[resultMapping mapKeyPath:@"tests" toRelationship:@"rides" withMapping: testTypeListMapping];

[[RKObjectManager sharedManager].mappingProvider setMapping:listMapping forKeyPath:@"result"];

RKObjectMapping *resultInverseMapping = [resultMapping inverseMapping];
resultInverseMapping.rootKeyPath = @"result";
Gonzalo.-
  • 12,512
  • 5
  • 50
  • 82
user667673
  • 171
  • 1
  • 5

0 Answers0