- Home /
json (LitJSON) from PHP array.. How?
I can't figure out how to get an array which has been received via WWW, from a PHP server. More specifically, I don't know what the type should be.
The data I receive from php, is sent via a standard json_encode() and received fine in Unity:
[[],{"score":"2821"},{"score":"575"}]
The problem occurs when trying to get json to "unpack" it:
I've tried:
string[] str = JsonMapper.ToObject<string[]>(www.text);
Which gives this error in Unity: JsonException: Type System.String can't act as an array.
Same for anything else I throw at it, even an ArrayList..
It's something quite obvious, I know it, can someone help?
Is this C or JS? In JS the default string type is written with capital S : String
. In C# that would be correct. I never worked with Json$$anonymous$$apper so can't say anything about that. Are you sure you can convert an object deffinition into a simple string array? I guess you need a Hashtable or Dictionary. Or what do you expect to get in the strings? The value, the name or both?