Sign In Register

How can we help you today?

Start a new topic

ScriptData response to Unity collection

 Hello,


I am trying to retrieve the data from a scriptData in a LogEventRequest response in Unity. It is set to return the below:   

{
    "Card1": {
        "String1": "Hipólito María",
        "String2": "test",
        "CardImage": 22,
        "Int1": 19,
        "String3": "None",
        "String4": "GK",
            "Int2": 10,
            "Int3": 10,
            "Int4": 10,
            "Int5": 10,
            "Int6": 10,
            "Int7": 10,
            "Int8": 10,
            "Int9": 10,
            "Int10": 10,
            "Int11": 10,
            "Int12": 10,
            "Int13": 10,
            "Int14": 10,
            "Int15": 10,
            "Int16": 10,
            "Int17": 10,
            "Int18": 10,
            "Int19": 10,
            "Int20": 10,
            "Int21": 10,
        "Status": "Substitution",
        "Rarity": "Very Common"
    }
}

    This is my code:

 

new LogEventRequest().SetEventKey("LOAD_CARD1").Send((response) => {
            if (!response.HasErrors)
            {
                //getting the ScriptData JSON
                  GSData data = response.ScriptData.GetGSData("response_Card1");
               //Extracting values one by one            
                  string name = data.GetGSData("Card1").GetString("Name"));
             }
        });

 and it works fine. 


But there are a lot of key-value pairs (and there will be 15 cards all with those keys each) in the response and getting all of them individually doesn't seem like the most performance-friendly option.


Idealy I would like to store them all in a array/list/dictionary but all the answers I found on the forum deal with GetObjectList which is now deprecated.


Can anyone help me with a solution to this please? :) 


Many thanks!!


1 Comment

Hi Alex,


I believe this Unity guide should be useful for you here. If you have any further questions on the GameSparks side just let us know.


Regards,

Liam

Login to post a comment