0

This might seems like a beginner question Apreciating any kind of solution,
im emiting this event from the server and give the obj a value, this is my client side

private void OnStart(SocketIOEvent obj){
    if (obj != null) {
        JSONObject json = obj.data;
        id = json ["id"].str;
        indexPlayer = Convert.ToInt32(json ["num"].str);
        currentPlayer.GetComponent<Player>().AddPlayer (id, indexPlayer);
        Debug.Log(json);
    } else {
        Debug.Log ("NULL Data");
    }
}

the result of debug would be like this

{"id":"rJAkjUv5f","num":"1"}

this is because i convert all my integer to string before pass it to client
it's working but the matter is when i need to shuffle an array of index from the server to client, i try some way to convert an array of int to string but its not working. Began to wondering how to get int from a JSON object

let say this is my json data,

{"collection":[1]}

how do i get it?

Im using Unity with Nodejs server and Socket IO.

Programmer
  • 121,791
  • 22
  • 236
  • 328
  • What? This is java? How is that related to nodejs? What do you want exactly? – Jonas Wilms Mar 27 '18 at 06:18
  • Paste your json [here](http://json2csharp.com/) and you should get an Object. Use JsonUtility from the duplicate to get your int. By the way, that's a List. I also removed the unnecessary tags from your question. – Programmer Mar 27 '18 at 06:19
  • @Programmer Wow Thank you so much it seems like i dont even know what the keyword to search , thats why i cant even find it anywhere – Vincent Wedison Mar 27 '18 at 06:34
  • No problem. We all start from somewhere – Programmer Mar 27 '18 at 06:45

0 Answers0