title: "The data couldn’t be read because it is missing" error when decoding JSON in Swift
body: <p>I am getting the following error :</p>
  
  <p>The data couldn’t be read because it is missing.</p>
  
  <p>When I run the following code:</p>
  
  <pre><code>struct Indicator: Decodable {
      let section: String
      let key: Int
      let indicator: Int
      let threshold: Int
  }
      var indicators = [Indicator]()
  
      do {
          if let file = Bundle.main.url(forResource: "indicators", withExtension: "json") {
              indicators = try JSONDecoder().decode([Indicator].self, from: try Data(contentsOf: file))
          }
      } catch {
          print(error.localizedDescription)
      }
  </code></pre>
  
  <p>These are in a function, but I have removed them for clarity. I have a code block which is very similar in a different file (I copied this code from there and changed the names essentially) so I'm not sure why it's happening. The json file is valid json and has it's target properly set.</p>
  
  <p>Thanks</p>