0
我发送一个WWW请求并获得正确的JSON响应,但我不知道我在做什么错误,将JSON字符串反序列化成字典。这是代码:Unity MiniJSON:无法反序列化WWW响应
IEnumerator requestScores(int level)
{
WWW jsonScores = new WWW(requestScoresURL + level);
yield return jsonScores; //Wait for download to complete
float elapsedTime = 0.0f;
while (!jsonScores.isDone)
{
elapsedTime += Time.deltaTime;
if (elapsedTime >= 10.0f) break;
yield return null;
}
if (!jsonScores.isDone || !string.IsNullOrEmpty(jsonScores.error))
{
Debug.LogError(string.Format("Fail Whale!\n{0}", jsonScores.error));
yield break;
}
string response = jsonScores.text;
Debug.Log(elapsedTime + " : " + response);
// Here "search" gets null value
Dictionary<string, object> search = Json.Deserialize(response) as Dictionary<string, object>;
}
所以jsonScores.txt
正确就取回我可以告诉,但Dictionary<string,object> search
出来为空,我究竟做错了什么?
在此先感谢!