IPhone : Not able to get NSDictionary from NSString

on Tuesday, March 31, 2015

I am trying to get NSDictionary from NSString.



NSString *report;
NSLog(@"report=%@",report);


//log



report = {
54a2a78f8502f958eecfcfc0 = Gjfcff;
54a2a78f8502f958eecfcfc1 = {
"_id" = 539affbb012bad66a0cd1d79;
data = "something";
};
"_id" = 54c77db48502f94891cb6f90;
date = "27-01-2015 17:29:48";
"modified_on" = "27-01-2015 17:29:48";
"record_version" = "0.01";
sequence = "0.02";
status = status;
user = 53983594012bad299f28869f;
}


//I have tried like this: -



NSData *data = [report dataUsingEncoding:NSUTF8StringEncoding];
NSLog(@"NSDATA = %@",data);

NSError* error;
NSDictionary *myData = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];


I am getting error :-



Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be
completed. (Cocoa error 3840.)" (No string key for value in object
around character 6.) UserInfo=0x156dcda0 {NSDebugDescription=No
string key for value in object around character 6.}


Whats going wrong?


0 comments:

Post a Comment