json data working
This commit is contained in:
@@ -9,17 +9,17 @@ public class DatabaseData : MonoBehaviour
|
||||
{
|
||||
public TMP_InputField input;
|
||||
private WriteFile wf;
|
||||
private PlayerList pl;
|
||||
protected string jsondata;
|
||||
public PlayerList players;
|
||||
public string jsondata;
|
||||
|
||||
private void Start() {
|
||||
wf = FindObjectOfType<WriteFile>();
|
||||
pl = new PlayerList();
|
||||
players = new PlayerList();
|
||||
}
|
||||
|
||||
public void jsonParser(string jsondata) {
|
||||
pl = JsonUtility.FromJson<PlayerList>(jsondata);
|
||||
pl.kiir();
|
||||
players = JsonUtility.FromJson<PlayerList>("{\"player\":" + jsondata + "}");
|
||||
players.kiir();
|
||||
}
|
||||
|
||||
public void GetPlayerData() => StartCoroutine(IGetPlayerData());
|
||||
@@ -39,8 +39,8 @@ public class DatabaseData : MonoBehaviour
|
||||
input.text = request.error;
|
||||
} else {
|
||||
jsondata = request.downloadHandler.text;
|
||||
jsonParser(jsondata);
|
||||
Debug.Log(jsondata);
|
||||
jsonParser(jsondata);
|
||||
input.text = jsondata;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ using UnityEngine;
|
||||
|
||||
[System.Serializable]
|
||||
public class Player {
|
||||
public int playerid;
|
||||
public string username;
|
||||
public Date joindate;
|
||||
public int player_id;
|
||||
public string player_name;
|
||||
public string player_join_date;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@ using UnityEngine;
|
||||
[System.Serializable]
|
||||
public class PlayerList
|
||||
{
|
||||
public Player[] players;
|
||||
public Player[] player;
|
||||
|
||||
public void kiir() {
|
||||
foreach(Player p in players) {
|
||||
Debug.Log("p_id: " + p.playerid + " username" + p.username);
|
||||
foreach(Player p in player) {
|
||||
Debug.Log("p_id: " + p.player_id + " username" + p.player_join_date);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user