title: Trouble parsing JSON
body: <p>I am having trouble parsing some JSON in Swift. I am having trouble getting the <code>errors</code> variable it returns nil. I think it should be a dictionary?
  Below is the JSON that is returned from my API as printed in the console.</p>
  
  <pre><code>{
      error = "{\"name\":[\"The name has already been taken.\"],\"email\":[\"The email has already been taken.\"]}";
      success = 0;
  }
  </code></pre>
  
  <p>And here is the Swift code.</p>
  
  <pre><code>do {
      let json = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as? NSDictionary
  
      if let parseJSON = json {
          print(parseJSON)
          let success = parseJSON["success"] as? Int
  
          if(success == 1) {
              let myAlert = UIAlertController(title: "Alert", message: "Registration successful", preferredStyle: UIAlertControllerStyle.alert);
  
              let okAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.default){
                  (action) in
                  self.dismiss(animated: true, completion: nil)
              }
  
              myAlert.addAction(okAction);
              self.present(myAlert, animated: true, completion: nil)
          } else {
              let errors = parseJSON["error"] as? NSDictionary
              if(errors != nil){
                  print("NOT NIL")
                  // self.displayAlertMessage()
              }
          }
      }
  } catch{
      print(error)
  }
  </code></pre>
  
  <p><strong>EDIT</strong>
  Here is the JSON thats is printed using David's code below.
  This is the parseJSON printed to the console.</p>
  
  <pre><code>["error": {"name":["The name has already been taken."],"email":["The email has already been taken."]}, "success": 0]
  </code></pre>
  
  <p>Here is my full method with Davids updated code.</p>
  
  <pre><code>let task = URLSession.shared.dataTask(with: request) { (theData: Data?, response: URLResponse?, theError: Error?) in
  
      DispatchQueue.main.async
          {
  
              //spinningActivity!.hide(true)
  
              if theError != nil {
                  self.displayAlertMessage(theError!.localizedDescription)
                  return
              }
  
              do {
                  guard let parseJSON = try JSONSerialization.jsonObject(with: theData!) as? [String:Any] else {return}
                  //print(parseJSON)
                  let success = parseJSON["success"] as? Int
                  if(success == 1) {
                      let myAlert = UIAlertController(title: "Alert", message: "Registration successful", preferredStyle: UIAlertControllerStyle.alert);
  
                      let okAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.default){
                          (action) in
                          self.dismiss(animated: true, completion: nil)
                      }
  
                      myAlert.addAction(okAction);
                      self.present(myAlert, animated: true, completion: nil)
                  } else {
                      guard let errors = parseJSON["success"] as? Int else {return}
                      print(errors)
                  }
              } catch{
                  print(error)
              }
  
  
  
      }
  
  }
  
  task.resume()
  </code></pre>