![](/img/trans.png)
[英]Unity Facebook SDK Fatal error after Facebook webview login
[英]Unity Facebook SDK, can't retrieve Country from Dictionary after Login
我正在检索以下Facebook用户所在的国家/地区:
void Get()
{
FB.API("/me?fields=location{location{country}}", HttpMethod.GET,this.callback1);
}
private void callback1(IResult result)
{
if (result.Error != null)
{
Debug.Log("FB.API result = null");
}
else
{
Dictionary<string, object> dict = Facebook.MiniJSON.Json.Deserialize(result.RawResult) as Dictionary<string, object>;
}
}
这很好。
JSON看起来像:
{
"location": {
"location": {
"country": "England"
},
"id": "111122233344"
},
"id": "1112299000"
}
问题是dict
结果就像嵌套字典一样,我找不到直接检索国家名称的方法。
我无法从头到尾测试此端到端,从文档中得出的结果应如下所示:
var dict = Json.Deserialize(jsonString) as Dictionary<string,object>;
object locationH;
string country;
if(dict.TryGetValue ("location", out locationH)) {
var location = (((Dictionary<string, object>)locationH) ["location"]);
var countryDict = (((Dictionary<string, object>)location) ["country"]);
country = (string)countryDict;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.