Я создаю JSON
для отправки в службе по проверке онлайн своей ошибки, показывающей:создания JSON в Objective C, недействительны JSON
Error: Parse error on line 1: [{\ "SAHExpertCode\" --^ Expecting 'STRING', '}', got 'undefined' My JSON is [{\"SAHExpertCode\" : \"\", \"ShiftType\" : \"AM\", \"LocFunId\" : \"CLT0004218\", \"SAHQualCode\" : \"CA\" }] Please tell me what's wrong and how to correct it.First i am making JSON filterString = [{ "SAHExpertCode" : "", "ShiftType" : "AM", "LocFunId" : "CLT0004218","SAHQualCode" : "CA" }] on checking found it is correct then creating a dictionary NSDictionary*[email protected]{@"MbrId":[USER_DEFAULTS valueForKey:@"MemberId"],@"StrFilter":[NSString stringWithFormat:@"%@",filterString],@"shiftCrtlNos":shftCntrlNmbrs}; NSMutableArray *finalArray = [[NSMutableArray alloc]init]; [finalArray addObject:dictData]; NSString *finalString =[self ConvertArrayToJsonData:finalArray];finalString = [finalString stringByReplacingOccurrencesOfString:@"\n" withString:@""]; finalString = [finalString stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]];after creation of final string it is generating symbol \ for JSON Conversion my code is -(NSString *)ConvertArrayToJsonData:(NSMutableArray *)array{ NSError error; NSData jsonData = [NSJSONSerialization dataWithJSONObject:array options:NSJSONWritingPrettyPrinted error:&error]; NSString *JSONString; if (!jsonData) { NSLog(@"error :%@",error); } else {JSONString = [[NSString alloc] initWithBytes:[jsonData bytes] length:[jsonData length] encoding:NSUTF8StringEncoding]; // NSLog(@"jsonstring:%@",JSONString); } return JSONString; } //i need JSON like [ { "StrFilter" : "[ { \"SAHExpertCode\" : \"\", \"ShiftType\" : \"PM\", \"LocFunId\" : \"CLT0004218\", \"SAHQualCode\" : \"CA\" }]", "MbrId" : "MBR0000035", "shiftCrtlNos" : "0080013526,0080014697" }] also tell me how to remove \ from String
вы можете разместить код, как вы генерирующий запрос & JSON также, чтобы мы могли помочь вам? – CodeChanger
Скажите, как именно вы хотите сделать JSON (Json Format). Дайте один образец. –
вопрос текст перепутался извините за это – niket