title: Adding JSON as asset and reading it
body: <p>I'm trying to load some JSON data from a local file. </p>
  
  <p>In <a href="https://developer.apple.com/library/ios/documentation/ToolsLanguages/Conceptual/Xcode_Overview/AddingDataSets.html" rel="noreferrer">this Apple doc</a> it says:</p>
  
  <blockquote>
    <p>Manage the data files for your app using the asset catalog. A file can
    contain any sort of data except device executable code generated by
    Xcode. <strong>You can use them for JSON files, scripts, or custom data types</strong></p>
  </blockquote>
  
  <p>So I added a new data set and dropped the JSON file inside. Now I can see it under Assets.xcassets folder (Colours.dataset folder with colours.json and Contents.json inside it)</p>
  
  <p>I found <a href="https://stackoverflow.com/questions/24410881/reading-in-a-json-file-using-swift">this</a> SO answer that shows how to read a JSON file and I'm using this code to read the file:</p>
  
  <pre><code>if let filePath = NSBundle.mainBundle().pathForResource("Assets/Colours", ofType: "json"), data = NSData(contentsOfFile: filePath) {
  
          print (filePath)
  
          do {
              let json = try NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.AllowFragments)
              print(json)
          }
          catch {
  
          }
      } else {
          print("Invalid file path")
      }
  </code></pre>
  
  <p>But this code is printing <em>"Invalid file path"</em> and not reading the file. I also tried "Colours" and "Colours.json" but to no avail.</p>
  
  <p>Could anyone please tell me how to properly add a local JSON file and read it?</p>
  
  <p>Thanks.</p>