标签:order 网络 des 分割 success 后台 div log data
项目中,需要将NSArray数组发送给后台,结果里面有空格,换行识别不了
batchTransNoOrder] line:125 content:param:{ fromSlId = 30532; lcCode = G046; operater = admin; orderId = ZCG04620171117000004; toSlId = 30535; trayCodes = ( G04620171106000000287, G04620171101000000180 ); whId = 192; } function:__65+[HttpTask doPostToServer:needToken:param:sucessBlock:failBlock:]_block_invoke line:105 content:接收到的服务器端的数据为:{"msg":"[(\n G04620171106000000287, G04620171101000000180\n)]找不到托盘数据!","success":false}
和后台沟通解决方法有两种:
1 将NSArray 转换为JSON字符串传给后台
NSArray *trayCodes = @[@"123",@"456"]; NSError *error = nil; NSData *jsonData = [NSJSONSerialization dataWithJSONObject:trayCodes options:kNilOptions error:&error]; NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
2 将NSArray 用分割符分割为字符串
NSArray *trayCodes = @[@"123",@"456"]; NSString *jsonStr = [trayCodes componentsJoinedByString:@","];
如果数组里面是对象,或者字典,请参考:http://blog.csdn.net/worldzhy/article/details/49982491
iOS 将NSArray、NSDictionary转换为JSON格式进行网络传输
标签:order 网络 des 分割 success 后台 div log data
原文地址:http://www.cnblogs.com/mnstar/p/7850781.html