Here is a response I get from a server:
{
result = {
blankfill = "[[1, [u'32354'], False, 7]]";
choice = "[[13, [3], False, 11], [10, [0], False, 3], [9, [1], False, 3], [2, [2], False, 4], [3, [1], False, 3], [1, [2], False, 3]]";
spendTime = 26;
};
retcode = 0;
subjectid = 1;
submittime = "2016-05-24T15:21:50.784";
}
choice is the string I want to convert to NSArray, it also contains nested arrays.
Here is the code I tried:
NSString *jsonString = [responseObject[@"result"] objectForKey:@"choice"];
NSData *data = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
NSArray *arr = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
Currently, arr is always nil.
Falseas value, see json.org. However, it would havefalse.u'32354'is also not a value.JSONObjectWithData:options:error:is called, it should gets transformed, but it can't be transformed because it is not a valid JSON, sinceFalsedoesn't exist in JSON