Xcode 4.6 を使用しています。一重引用符が適切にエスケープされた有効な Json 文字列をサーバーから取得します。サーバー上のフィールドから一重引用符を削除すると、エラーは発生しません。
json文字列は次のとおりです。
jsonStr: '{ "status": 0, "message": "success", "object": [ { "currentthreatlevelname": "Guarded", "devicename": "Virendra\'s Pad", "threatlevelname": null, "enabled": false, "practicemode": false, "locationname": null, "currentthreatlevel": 3, "status": 0, "deviceid": "APLFC8C49AF-D4DF-4AE0-9E7B-D2A3E94ED387", "threatlevel": null, "location": null } ], "site": "s2 security" }'
によって生産
NSString* jsonStr = [[NSString alloc] initWithData:_receivedData encoding:NSUTF8StringEncoding];
解析コードは次のとおりです。
NSDictionary *d = [NSJSONSerialization JSONObjectWithData: _receivedData
options:NSJSONReadingMutableContainers|NSJSONReadingAllowFragments
error:&jsonError];
助けてください。ありがとう。