c# - Unity MiniJSON: Can't deserialize WWW response -
i'm sending www request , getting proper txt response in json, i'm not sure i'm doing wrong deserialize json string dictionary. code:
ienumerator requestscores(int level) { www jsonscores = new www(requestscoresurl + level); yield homecoming jsonscores; //wait download finish float elapsedtime = 0.0f; while (!jsonscores.isdone) { elapsedtime += time.deltatime; if (elapsedtime >= 10.0f) break; yield homecoming 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) dictionary<string, object>; }
so jsonscores.txt
retrieved correctly far can tell dictionary<string,object> search
comes out null, doing wrong?
thanks in advance!
ok found wrong in there, getting multiple rows needed deserialize list of dictionaries instead of single one.
this code worked:
list <dictionary<string, object>> list;
...
list = json.deserialize(response) list<dictionary<string, object>>; foreach (dictionary<string, object> row in list) { // whatever row }
c# json unity3d
No comments:
Post a Comment