I am trying to deserialize this js object in Unity
{
"1":{
"id":1,
"name":"John",
"score":0,
"character":0,
"position":{
"x":0,
"y":1.069696307182312,
"z":0
}
},
"2":{
"id":2,
"name":"Matt",
"score":0,
"character":0,
"position":{
"x":0,
"y":1.069696307182312,
"z":0
}
}
}
I have tried a [Serializable] class with list inside and Dictionary inside:
[Serializable]
public class Players
{
public List<Player> players;
}
[Serializable]
public class DictPlayers
{
public Dictionary<string,Player> players;
}
[Serializable]
public class Player
{
public string name;
public int score;
public int character;
public int id;
public Vector3 position;
}
These come up just as empty lists:
public Players networkPlayers;
public DictPlayers testNestedDict;
testNestedDict = JsonUtility.FromJson<DictPlayers>(payload);
networkPlayers = JsonUtility.FromJson<Players>(payload);
Any new ideas? Tried with Newtonsoft json also. Json stringify and just sending plain obj result the same.