Facebook KeyNotFoundException即使关键存在

时间:2014-10-23 00:57:02

标签: c# facebook dictionary unity3d facebook-unity-sdk

所以我使用的是Facebook Unity API,无法弄明白为什么我会KeyNotFoundException: The given key was not present in the dictionary.

我试图获取用户的姓氏。名字工作正常。我在行中打印Facebook响应,之前包括" last_name"关键,但我仍然得到例外。

void APICallback(){
    Dictionary<string,string> profile = Util.DeserializeJSONProfile(result.Text);  
    print (result.Text);
    currentUser["Name"] = profile["first_name"];
    currentUser["LastName"] = profile["last_name"];
}

这是result.Text

{"id":"XXXXXXX","first_name":"David","last_name":"Richard","friends":{"data":[],"summary":{"total_count":58}}}

1 个答案:

答案 0 :(得分:0)

它必须是Util.DerializeJSONProfile的错误我使用SimpleJson来解析result.Text并且它完美无缺。