我從服務器中檢索json文件,然後使用Json反序列化內容。我如何不斷收到此錯誤:無法從源類型轉換爲目標類型Json
Cannot cast from source type to destination type
我按照Minijson腳本的步驟,但仍然出現此錯誤。一些幫助將不勝感激。
void Start() {
//creating url
image1Request = new WWW("http://development.someurl.com/MoreGames/MoreGames.json");
StartCoroutine(ImageOne(image1Request));
}
IEnumerator ImageOne(WWW www)
{
//wait until url is loaded
yield return www;
//load image into texture slot
if (www.error == null)
{
//assigning URLS
var dict = Json.Deserialize(www.text) as Dictionary<string,object>;
Debug.Log(www.text);
Debug.Log("deserialized: " + dict.GetType());
Debug.Log("dict['string']: " + (string)dict["widget"]);
}
else
{
Debug.Log("WWW Error: " + www.error);
}
}
什麼'的Json 。反序列化返回?它似乎不是一個'Dictionary'。 –