【发布时间】:2014-10-23 00:57:01
【问题描述】:
所以我正在使用 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}}}
【问题讨论】:
-
如果您打印配置文件,它包含什么?
-
System.Collections.Generic.Dictionary`2[System.String,System.String] 我不确定如何在 Unity 中打印完整的字典
-
遍历它并打印密钥
-
好的,所以我这样做了,它打印的只是“first_name”键。但结果包括“id”和“last_name”。没看懂
标签: c# facebook dictionary unity3d facebook-unity-sdk