title: Getting the count (number of items) in a json response in swift
body: <p>I am on the process of learning swift now. I have used ANetworking (library in Obj C) in my swift code. I have successfully been able to return the parsed JSON. However I would want to find the count of the json items that are returned. Here is what I did so far:</p>
  
  <pre><code>//in viewDidAppear function
  manager.GET(url,
          parameters: nil,
          success: { (operation: AFHTTPRequestOperation!, responseObject: AnyObject!) in
              self.jsonFunc(responseObject.description)
  </code></pre>
  
  <p>I did the above like this question in stackoverflow: <a href="https://stackoverflow.com/questions/24549627/afnetworking-and-swift-save-json-response">AFNetworking and Swift - Save json response</a></p>
  
  <p>Now, in the function jsonFunc, I am trying to get the count of the json data as so:</p>
  
  <pre><code>func jsonFunc(data: AnyObject) {
      let count: Int? = data.count // I understand that data is AnyObject. How to typecast and get the number of data items here?
      if let ct = count {
          println(ct)
          for index in 0...ct-1 {
  
            if let parsedData = data[index] as? [String: AnyObject] {               
                      println(parsedData)
             }
          }
       }
   }
  </code></pre>
  
  <p>What is the conversion mistake that I am doing/missing here?</p>