- (NSString *)pictureArrayToJSON:(NSArray *)picArr {
NSData *data=[NSJSONSerialization dataWithJSONObject:picArr options:NSJSONWritingPrettyPrinted error:nil];
NSString *jsonStr=[[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
//去除空格和回车:
jsonStr = [jsonStr stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
jsonStr = [jsonStr stringByReplacingOccurrencesOfString:@" " withString:[@""](https://my.oschina.net/u/2433434)];
jsonStr = [jsonStr stringByReplacingOccurrencesOfString:@"\n" withString:[@""](https://my.oschina.net/u/2433434)];
NSLog(@"jsonStr==%@",jsonStr);
return jsonStr;
}
网友评论