Hi
I am struggling to understand why i am getting this error and hoping someone can spot the problem:
public void PrintUserTips()
{
string json = File.ReadAllText(Application.persistentDataPath + "/usertips.json");
Debug.Log("json for tips: " + json);
//**** error is happening here
PlayerTipsJSON loadedPlayerData = JsonUtility.FromJson<PlayerTipsJSON>(json);
int toppick = loadedPlayerData.data.Count;
for (int i = 0; i < loadedPlayerData.data.Count; i++)
{
Debug.Log(loadedPlayerData.data[i].ContentTitle + "\n");
Debug.Log(loadedPlayerData.data[i].ContentBody + "\n");
}
ContentBody.text = loadedPlayerData.data[RandomiserTip(toppick)].ContentBody;
ContentBody1.text = loadedPlayerData.data[RandomiserTip(toppick)].ContentBody;
ContentBody2.text = loadedPlayerData.data[RandomiserTip(toppick)].ContentBody;
}
[System.Serializable]
public class PlayerData
{
// public string fromJSONusername;
public string ContentTitle;
public string ContentBody;
}
[System.Serializable]
public class PlayerTipsJSON
{
public List<PlayerData> data;
}
here is the JSON file
[{"ContentTitle":"test data minimum value","ContentBody":"this is a test message that should display when the user value is greater than the minimum value"},{"ContentTitle":"test data maximum value","ContentBody":"this is a test message that should display when the user value is less than the maximym value"},{"ContentTitle":"test data boolean true","ContentBody":"This is a test message for content where boolean is true"}]
thanks