So I have to deserialize data from a file. It works fine for Windows and Mac, but doesnt for Android or iOS.
This is the code I have for Windows:
public void LoadAndDeserialize()
{
var streamReader = new StreamReader(PATH);
data = streamReader.ReadToEnd();
streamReader.Close();
questions = JsonUtility.FromJson<Questions> (data);
}
It works perfectly. Either with JSONFX or new JsonUtilities.
And this is the code I have for Android:
public void LoadAndDeserialize()
{
WWW adata = new WWW(PATH);
while ( !adata.isDone) {}
var streamReader = new StreamReader(adata.text);
data = streamReader.ReadToEnd();
streamReader.Close();
questions = JsonUtility.FromJson<Questions> (data);
}
I also tried deserializing directly from WWW:
questions = JsonUtility.FromJson<Questions> (adata.text);
But it wont work either. So, what Im doing wrong? Whats the way to deserialize data for Android?