title: Swift getting a value from key from json
body: <p>I have the following Json </p>
  
  <blockquote>
    <p>{
        "user": {
            "age": 0,
            "_id": "5d063d9fad424e0017e3113a",
            "name": "Superman 2",
            "email": "super@hotmail.com",
            "createdAt": "2019-06-16T13:01:19.350Z",
            "updatedAt": "2019-06-16T13:01:19.471Z",
            "__v": 1
        },
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1ZDA2M2Q5ZmFkNDI0ZTAwMTdlMzExM2EiLCJpYXQiOjE1NjA2OTAwNzl9.DECWm1TgEevUmOqgIAklEPFnfno23QfaUvggqORlpZE"
    }
    The problem is I dont know how to get the _id or name from the "user"</p>
  </blockquote>
  
  <p>I can get the "token" no problem.</p>
  
  <pre><code>let task = URLSession.shared.dataTask(with: request) { (data: Data?, response: URLResponse?, error: Error?) in
  
      self.removeActivityIndicator(activityIndicator: myActivityIndicator)
  
      if error != nil
      {
          self.displayMessage(userMessage: "Could not successfully perform this request. Please try again later")
          print("error=\(String(describing: error))")
          return
      }
  
  
      //Let's convert response sent from a server side code to a NSDictionary object:
      do {
          let json = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as? NSDictionary
  
          if let parseJSON = json {
  
  
              let userId = parseJSON["userId"] as? String
              print("User id: \(String(describing: userId!))")
  
              if (userId?.isEmpty)!
              {
                  // Display an Alert dialog with a friendly error message
                  self.displayMessage(userMessage: "Could not successfully perform this request. Please try again later")
                  return
              } else {
                  self.displayMessage(userMessage: "Successfully Registered a New Account. Please proceed to Sign in")
              }
  
          } else {
              //Display an Alert dialog with a friendly error message
              self.displayMessage(userMessage: "Could not successfully perform this request. Please try again later")
          }
      } catch {
  
          // Display an Alert dialog with a friendly error message
          self.displayMessage(userMessage: "Could not successfully perform this request. Please try again later")
          print(error)
             }
      }
  
      task.resume()
  </code></pre>
  
  <p>The results should show the values from <code>_id</code> and <code>name</code></p>