Having lots of trouble extracting the JSON skin data, as none of it is keyed ๐
getting the bones and slots like this:
NSArray *attachments = [SkeletonJSON objectForKey:@"bones"];
for(NSDictionary *object in attachments) {
NSLog(@"%@", [object objectForKey:@"name"]);
NSLog(@"%@", [object objectForKey:@"parent"]);
NSLog(@"%@", [object objectForKey:@"length"]);
NSLog(@"%@", [object objectForKey:@"x"]);
NSLog(@"%@", [object objectForKey:@"y"]);
NSLog(@"%@", [object objectForKey:@"scaleX"]);
NSLog(@"%@", [object objectForKey:@"scaleY"]);
NSLog(@"%@", [object objectForKey:@"rotation"]);
}
NSArray *attachments1 = [SkeletonJSON objectForKey:@"slots"];
for(NSDictionary *object in attachments1) {
NSLog(@"%@", [object objectForKey:@"name"]);
NSLog(@"%@", [object objectForKey:@"bone"]);
NSLog(@"%@", [object objectForKey:@"color"]);
NSLog(@"%@", [object objectForKey:@"attachment"]);
}
Finally (after much trial and error) getting the skin info using this code, although it doesn't seem so intuitive ..... (plus I don't have a Spine export with an attachment 'type', so not reading that yet)
NSDictionary *skinNames = [SkeletonJSON objectForKey:@"skins"];
NSArray*keys=[skinNames allKeys];
for (int i=0; i<[keys count]; i++) {
NSLog(@"Skin %@",keys[i]);
NSDictionary *slotNames = [skinNames objectForKey:keys[i]];
NSArray*keys1=[slotNames allKeys];
for (int ii=0; ii<[keys1 count]; ii++) {
NSDictionary *attachmentNames = [slotNames objectForKey:keys1[ii]];
NSLog(@"Slot %@",keys1[ii]);
NSArray*keys2=[attachmentNames allKeys];
for (int iii=0; iii<[keys2 count]; iii++) {
NSLog(@"Attachment %@",keys2[iii]);
NSDictionary *attachments2 = [attachmentNames objectForKey:keys2[iii]];
NSLog(@"%@", [attachments2 objectForKey:@"x"]);
NSLog(@"%@", [attachments2 objectForKey:@"y"]);
NSLog(@"%@", [attachments2 objectForKey:@"scaleX"]);
NSLog(@"%@", [attachments2 objectForKey:@"scaleY"]);
NSLog(@"%@", [attachments2 objectForKey:@"rotation"]);
NSLog(@"%@", [attachments2 objectForKey:@"width"]);
NSLog(@"%@", [attachments2 objectForKey:@"height"]);
}
}
}