I have a JSON return being formatted and saved into a plist, it looks like the following:
I need it to have the following format:
I'm missing something in the saving of the array so I can add the "Rows" below the Root and "Item 0, etc" under the profile, any ideas?
Here is my code:
NSURL *url = [NSURL URLWithString:@"http://10.0.1.8/~imac/iphone/jsontest.php"];
NSString *jsonreturn = [[NSString alloc] initWithContentsOfURL:url];
NSLog(jsonreturn); // Look at the console and you can see what the results are
SBJSON *json = [[SBJSON alloc] init];
NSError *error = nil;
rowsArray= [json objectWithString:jsonreturn error:&error];
//ADDED from COMMENT AS TEST
test = [rowsArray valueForKey:@"member"];
//Saving
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *choiceR = [documentsDirectory stringByAppendingPathComponent:@"FollowingArray"];
NSMutableArray *array = [[NSMutableArray alloc] init];
NSLog(@"string: %@",choiceR);
[array addObject:rowsArray];
[array writeToFile:choiceR atomically:YES];
[array release];
[jsonreturn release];
[json release];
Here is the test plist from the test: