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
出來爲空,我究竟做錯了什麼?
在此先感謝!