I am trying to build Multiplayer game where Java is my server and Unity is my Clinet. I am able to send data to server and read data in Json format in the server(Java Server) But when i try to read the response i am facing issues. I am unable to map properly the Json response to the Classes which are creatied in Unity.
Please find below.
public class Player
{
public string playerID;
public string name;
public string playerPosX;
public string playerPosY;
public string playerPosZ;
}
public class Lobby
{
public string lobbyID;
public ArrayList player;
}
lobby = JsonUtility.FromJson<Lobby>(response);
Debug.Log(lobby.lobbyID);
Debug.Log(lobby.player.Count);
I am getting the json data as
{"player":[{"playerID":"P1","name":"","playerPosX":"","playerPosY":"","playerPosZ":"","myne":false}],
"lobbyID":"L1"
}
and i am getting following error. at 2nd log Object reference not set to an instance of an object