Beispiel #1
0
    /// <summary>
    /// Parses a game from a json string
    /// </summary>
    /// <param name="json">The parsed game object</param>
    /// <returns></returns>
    public static Game FromJson(string json)
    {
        JsonGame jsonGame = JsonUtility.FromJson <JsonGame>(json);

        Game game = new Game(jsonGame.id, jsonGame.description, jsonGame.commType);

        return(game);
    }
Beispiel #2
0
    void PrintResults(string rawJson)
    {
        // Raw output:
        Debug.Log("******** raw string from Twitter ********");
        Debug.Log(rawJson);

        // Turn the JSON into C# objects
        gameJSON = JsonReader.Deserialize <JsonGame>(rawJson);

        // iterate through the array of results;
        Debug.Log("******** search results ********");

        Debug.Log("Players: " + gameJSON.players.Length);
        Debug.Log("Entities: " + gameJSON.entities.Length);
        Debug.Log("Cards: " + gameJSON.entities.Length);

        /*
         * foreach (var player in gameJSON.players)
         * {
         *  //Debug.Log("player id: " + player.id + ", player name: " + player.name);
         *
         * }
         *
         * foreach (var entity in gameJSON.entities)
         * {
         *  Debug.Log("entity row and col: " + entity.row + ", " + entity.col);
         *  Debug.Log("entity.id" + " : " + entity.id);
         *  Debug.Log("entity owners: " + entity.player_id + ", " + entity.game_id);
         * }
         * Debug.Log(gameJSON.whose_turn.id + " : " + gameJSON.whose_turn.name);
         *
         *
         * Debug.Log("******** serialize an entity ********");
         *
         * // this turns a C# object into a JSON string.
         * string json = JsonWriter.Serialize(gameJSON);
         *
         * Debug.Log(json);
         */
    }
Beispiel #3
0
    void PrintResults(string rawJson)
    {
        // Raw output:
        Debug.Log("******** raw string from Twitter ********");
        Debug.Log(rawJson);

        // Turn the JSON into C# objects
        gameJSON = JsonReader.Deserialize<JsonGame>(rawJson);

        // iterate through the array of results;
        Debug.Log("******** search results ********");

        Debug.Log("Players: " + gameJSON.players.Length);
        Debug.Log("Entities: " + gameJSON.entities.Length);
        Debug.Log("Cards: " + gameJSON.entities.Length);

        /*
        foreach (var player in gameJSON.players)
        {
            //Debug.Log("player id: " + player.id + ", player name: " + player.name);

        }

        foreach (var entity in gameJSON.entities)
        {
            Debug.Log("entity row and col: " + entity.row + ", " + entity.col);
            Debug.Log("entity.id" + " : " + entity.id);
            Debug.Log("entity owners: " + entity.player_id + ", " + entity.game_id);
        }
        Debug.Log(gameJSON.whose_turn.id + " : " + gameJSON.whose_turn.name);

        Debug.Log("******** serialize an entity ********");

        // this turns a C# object into a JSON string.
        string json = JsonWriter.Serialize(gameJSON);

        Debug.Log(json);
         */
    }