Authored by ZhangTonghai
Committed by 朱小军

修改大数据上传时数据格式非法无法序列化的容错

review by yincheng
... ... @@ -73,6 +73,15 @@
NSError *error = nil;
NSMutableDictionary *actualParameters = [NSMutableDictionary dictionaryWithDictionary:parameters];
BOOL isValid = [NSJSONSerialization isValidJSONObject:actualParameters];
if (!isValid) { //校验上传数据格式合法性,如果不是合法的json格式,不再上传并删除本地文件,故返回YES
YALog(@"upload data dictionary is not valid json object");
if (block) {
block(YES, nil);
}
return nil;
}
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:actualParameters options:0 error:&error];
if (error) {
YALog(@"json parsing, connot convert to json for: %@\n code: %zd\n reason: %@", actualParameters, [error code], [error localizedDescription]);
... ... @@ -177,7 +186,14 @@
{
NSError *error = nil;
NSMutableDictionary *actualParameters = [NSMutableDictionary dictionaryWithDictionary:parameters];
BOOL isValid = [NSJSONSerialization isValidJSONObject:actualParameters];
if (!isValid) { //校验上传数据格式合法性,如果不是合法的json格式,返回错误
YALog(@"upload data dictionary is not valid json object");
if (block) {
block(NO, nil);
}
return nil;
}
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:actualParameters options:0 error:&error];
if (error) {
YALog(@"json parsing, connot convert to json for: %@\n code: %ld\n reason: %@", actualParameters, (long)[error code], [error localizedDescription]);
... ...