So i have this string that callback function gives which contains all the json data
private string jsonResponse = @"{""players""[{""name"":""cc"",""rank"":29}, ...]}";
And when i try to convert it from json to object using JsonUtility.FromJson it throws
Object reference not set to an instance of an object
I've created object classes(root and normal class) and it still doesn't work, here is the code:
void actionTest(int i, string s)
{
Debug.Log(i + " " + s);
Rootobject rootObj = new Rootobject();
rootObj = JsonUtility.FromJson<Rootobject>(s);
Debug.Log(rootObj.players.Count);
}
[System.Serializable]
public class Rootobject
{
public List<Player> players { get; set; }
}
[System.Serializable]
public class Player
{
public string name { get; set; }
public int rank { get; set; }
}
This all happens when a button is pressed!