所以我使用的是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}}}
答案 0 :(得分:0)
它必须是Util.DerializeJSONProfile
的错误我使用SimpleJson来解析result.Text
并且它完美无缺。