I have added a JSON-file to my file-system where the data is structured like this:
{ "DDD" : "3D Systems Corporation", "MMM" : "3M Company", "WBAI" : "500.com Limited", "WUBA" : "58.com Inc.", "AHC" : "A.H. Belo Corporation", "ATEN" : "A10 Networks, Inc.", "AAC" : "AAC Holdings, Inc.", "AIR" : "AAR Corp." }
my file-name is stockDict.json
and I'm trying to retrieve the data from it by using this code:
let jsonFilePath:NSString = NSBundle.mainBundle().pathForResource("stockDict", ofType: "json")!
let jsonData:NSData = NSData.dataWithContentsOfMappedFile(jsonFilePath as String) as! NSData
let error:NSError?
let json = JSON(jsonData)
println(json[0][0].string)
But all I get when it prints is nil
. What is wrong with my code?
Any suggestions would be appreciated.