如何使用 AFNetworking 检索 JSON 多数据?

How to retrieve JSON multi data with AFNetworking?

我在 Swift 中使用 AFNetworking 库。 当我检索单个数据 json 时 [{a:"xxx",b:"yyy"}] ,它成功了。 但是当我检索多数据 json 时 [{a:"xxx",b:"yyy"},{a:"mmm",b:"nnn"}],失败了。

    let manager:AFHTTPRequestOperationManager = AFHTTPRequestOperationManager()
    let serializer:AFJSONRequestSerializer = AFJSONRequestSerializer()
    manager.requestSerializer = serializer
    manager.GET("http://www.test.com/member.json", parameters: nil,
        success: {(operation: AFHTTPRequestOperation!, responsObject: AnyObject!) in
            let responsDict = responsObject as Dictionary<String, AnyObject>
        })

我想我应该将 responsObject Dictionary 的类型更改为其他类型。 但是我不知道。

请多多指教。

请检查以下示例以了解您缺少什么:

manager.GET( "https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quote%20where%20symbol%20in%20(%22AAPL%22)&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=",
    parameters: nil,
    success: {
        operation, responseObject in

        if let quote = responseObject?.objectForKey("query")?.objectForKey("results")?.objectForKey("quote") as? NSDictionary {

            let symbol = quote.objectForKey("Symbol") as? String
            let lastTradePriceOnly = quote.objectForKey("LastTradePriceOnly") as? String

            println("results: \(symbol) @ \(lastTradePriceOnly)")
        } else {
            println("no quote")
        }
    },
    failure: {
        operation, error in

        println("Error: " + error.localizedDescription)
    })