为什么SwifyJSON字典值为空?

为什么SwifyJSON字典值为空?,json,swift,swifty-json,Json,Swift,Swifty Json,我正在使用SwifyJSON解析通过socket.io发送到iOS应用程序的一些JSON,响应的.dictionaryValue为nil。以下是从服务器发送数据的方式: socket.emit('hasBeenMatched', {user: JSON.stringify(currentUser)}); 以下是我在iOS应用程序中得到的信息: socket.on("hasBeenMatched", callback: {data, ack in println("got

我正在使用SwifyJSON解析通过socket.io发送到iOS应用程序的一些JSON,响应的
.dictionaryValue
nil
。以下是从服务器发送数据的方式:

socket.emit('hasBeenMatched', {user: JSON.stringify(currentUser)});
以下是我在iOS应用程序中得到的信息:

    socket.on("hasBeenMatched", callback: {data, ack in
        println("got response after requesting match");

        let user = JSON(data!)
        println(user)
        println(user[0])
        println(user[0]["user"])
        println(user[0]["user"].dictionaryValue)

    })
下面是该代码的输出:

got response after requesting match
[
  {
    "user" : "{\"_id\":\"5511c3d8abcdc2fcf7b8fe4b\",\"email\":\"j\",\"password\":null,\"firstname\":\"j\",\"lastname\":\"j\",\"age\":9,\"radius\":\"9\",\"__v\":0,\"wantsToBeMatched\":true,\"matchedWith\":\"k k\"}"
  }
]
{
  "user" : "{\"_id\":\"5511c3d8abcdc2fcf7b8fe4b\",\"email\":\"j\",\"password\":null,\"firstname\":\"j\",\"lastname\":\"j\",\"age\":9,\"radius\":\"9\",\"__v\":0,\"wantsToBeMatched\":true,\"matchedWith\":\"k k\"}"
}
{"_id":"5511c3d8abcdc2fcf7b8fe4b","email":"j","password":null,"firstname":"j","lastname":"j","age":9,"radius":"9","__v":0,"wantsToBeMatched":true,"matchedWith":"k k"}
[:]
在代码的另一部分中,我有以下代码:

let request = Alamofire.request(.POST, "http://localhost:3000/api/users/authenticate", parameters: params)
request.validate()
request.response { [weak self] request, response, data, error in
    if let strongSelf = self {
        // Handle various error cases here....

        var serializationError: NSError?

        if let json: AnyObject = NSJSONSerialization.JSONObjectWithData(data!, options: .AllowFragments, error: &serializationError) {
            println(JSON(json).dictionaryValue)

            // Story board navigation
        } else {
            //Handle error case
        }
    }
}
编辑:Alamofire响应处理中的
println
输出如下所示:

[_id: 5511c3d8abcdc2fcf7b8fe4b, password: null, __v: 0, lastname: j, age: 9, wantsToBeMatched: true, firstname: j, radius: 9, email: j, matchedWith: k k]

我想知道的是:为什么
println(用户[0][“用户”].字典值)
导致
[:]

找到了答案,但我的解决方案与SwiftyJSON无关(我仍然很好奇)。我改变了服务器通过套接字发送数据的方式。我更改了socket.emit('hasBeenMatched',{user:JSON.stringify(currentUser)})to
socket.emit('hasBeenMatched',{user:currentUser})。基本上,我删除了手册