Is it possible if I have a NSString and I want to use NSJSONSerialization? How do I do this?
You need to convert your NSString
to NSData
, at that point you can use the +[NSJSONSerialization JSONObjectWithData:options:error:]
method.
NSString * jsonString = YOUR_STRING;
NSData * data = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
NSError * error = nil;
id json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
if (!json) {
// handle error
}