- Home /
Question by
floralDenis · Feb 20, 2017 at 09:39 AM ·
androidwwwjsondatastreamingassets
Streaming Assets android
Hello, everyone. I have a problem with reading data from json on android (using WWW JAR). 2-3 days ago it was working... Moreover, I can show obtained WWW.text file via UI.Text, but when I try to read the data from this WWW file via JsonUtility.FromJson I have a "Null reference exception". It must be said that on PC everything runs good (using System.IO). Help me, please. Thanks in advance.
public IEnumerator LoadLocalizedText(string fileName)
{
string path = "jar:file://" + Application.dataPath + "!/assets/" + fileName;
WWW www = new WWW(path);
yield return www;
string dataAsJson = www.text;
localizedText = new Dictionary<string, string>();
// I figured out that the problem occurs here. I got "Null reference exception" in console
LocalizationData loadedData = JsonUtility.FromJson<LocalizationData>(dataAsJson);
for (int i = 0; i < loadedData.items.Length; i++)
{
localizedText.Add(loadedData.items[i].key, loadedData.items[i].value);
}
isReady = true;
}
Comment