title: Playground Execution error: Signal SIGABRT while parsing JSON string
body: <p>I'm really not sure why the JSON parsing causes a SIGABRT error.    </p>
  
  <pre><code>class Bug {
      enum State {
          case open
          case closed
      }
  
      let state: State
      let timestamp: Date
      let comment: String
  
      init(state: State, timestamp: Date, comment: String) {
          self.state = state
          self.timestamp = timestamp
          self.comment = comment
      }
  
      init(jsonString: String) throws {
  
          let dict = convertToDictionary(from: jsonString)
  </code></pre>
  
  <p>I think this is what is causing the error but I couldn't figure out why:</p>
  
  <pre><code>        self.state = dict["state"] as! Bug.State
  
          self.comment = dict["comment"] as! String
  
          self.timestamp = dict["timestamp"] as! Date
      }
  }
  </code></pre>
  
  <p>JSON string to dictionary:</p>
  
  <pre><code>func convertToDictionary(from text: String) -&gt; [String: Any] {
      guard let data = text.data(using: .utf8) else { return [:] }
      let anyResult: Any? = try? JSONSerialization.jsonObject(with: data, options: [])
      return anyResult as? [String: Any] ?? [:]
  }
  
  enum TimeRange {
      case pastDay
      case pastWeek
      case pastMonth
  }
  </code></pre>
  
  <p>Error image: <a href="https://i.stack.imgur.com/ntU1h.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ntU1h.jpg" alt="enter image description here"></a></p>