我知道如何使用像
这样的restkit将对象转换为jsonUser* user = [User new];
user.firstName = @"Blake";
user.lastName = @"Watters";
RKObjectMapping *mapping = [RKObjectMapping mappingForClass:[NSDictionary class] ];
[mapping addAttributeMappingsFromArray:@[ @"firstName", @"lastName"] ];
RKRequestDescriptor *requestDescriptor = [RKRequestDescriptor requestDescriptorWithMapping:mapping objectClass:[User class] rootKeyPath:@"user" method:RKRequestMethodAny];
NSError* error;
NSDictionary *parameters = [RKObjectParameterization parametersWithObject:object requestDescriptor:requestDescriptor error:&error];
// Serialize the object to JSON
NSData *JSON = [RKMIMETypeSerialization dataFromObject:parameters MIMEType:RKMIMETypeJSON error:&error];
case1:如果它不仅仅是User对象,如果它像NSArray *用户那样;
case2:如果它不仅仅是User对象,如果它像NSArray *用户和User类有子类一样叫做课程,例如,如何让json发送到Web服务;