I Have got this Response from WebService
{"d":"{"token":"b502645e-837f-4237-a6ff-d4323f2799dd","timestamp":"09/11/20147:46:43PM"}"}
I want to Parse this String so that i can get output like : token = b502645e-837f-4237-a6ff-d4323f2799dd timestamp = 09/11/20147:46:43PM So that i can Store it into Database.
This is my Code
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
// The request is complete and data has been received
// You can parse the stuff in your instance variable now
/*
NSError *errorJson=nil;
NSString* OuterDict = [NSJSONSerialization JSONObjectWithData:receivedData options:kNilOptions error:&errorJson];
NSLog(@"Outer Dictionary %@",OuterDict);
*/
NSString *responseData = [[NSString alloc]initWithData:receivedData encoding:NSUTF8StringEncoding];
responseData = [responseData stringByReplacingOccurrencesOfString:@" " withString:@""];
responseData = [responseData stringByReplacingOccurrencesOfString:@"\\" withString:@""];
//NSString* encodedString = [responseData stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
//NSLog(@"%@",encodedString);
NSLog(@"Reponse data %@",responseData);
NSError *errorJson=nil;
NSData *jsonData = [responseData dataUsingEncoding:NSUTF8StringEncoding];
jsonData = [jsonData subdataWithRange:NSMakeRange(0, [jsonData length] - 1)];
NSDictionary* OuterDict = [NSJSONSerialization JSONObjectWithData:jsonData options:kNilOptions error:&errorJson];
NSLog(@"Outer Dict %@",OuterDict);
}
I am getting null
as Output:
Outer Dict (null)
Can Anyone Help me With this. Thanks In Advance.