Reputation: 444
How can i compress my NSDictionary
object which is in JSON format? Do demonstrate, my current object is like that:
And i want to make it be like that:
Can you help me about that? Thanks in advance.
Upvotes: 1
Views: 307
Reputation: 4294
It seems that you want to remove all the whitespaces, try this:
NSData *data = [NSJSONSerialization dataWithJSONObject:dic options:0 error:nil];
NSString *jsonString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
jsonString = [jsonString stringByReplacingOccurrencesOfString:@"\\s"
withString:@""
options:NSRegularExpressionSearch
range:NSMakeRange(0, [jsonString length])];
Upvotes: 1