caipivara
8/20/2014 - 4:13 AM

Category to get a string from an array of JSONModel objects using JSONModel 1.0.1

Category to get a string from an array of JSONModel objects using JSONModel 1.0.1

#import "NSArray+JSON.h"

@implementation NSArray (CRNSArrayJSON)

-(NSString*) toJSONString
{
    // src=http://stackoverflow.com/a/18219972/273119
    
    NSMutableArray* jsonObjects = [NSMutableArray new];
    
    for ( id obj in self )
    {
        [jsonObjects addObject:[obj toJSONString]];
    }
    
    return [NSString stringWithFormat:@"[%@]",
            [jsonObjects componentsJoinedByString:@","]];
}


@end
#import "JSONModel.h"

@interface NSArray (CRNSArrayJSON)

- (NSString*)toJSONString;

@end